PDA

View Full Version : Text To Hex Converter[C++]



SonniE
06-02-2008, 04:42 AM
This is similar to my Char to hax/deci but u can do a string such as a word the value generated is same value as u would see in nitepr or ps2dis


/*
Name: Text Converter
Author: SonniE
Date: 02/06/08 04:30
Description: www.codinghs.com original program
*/

#include <iostream>
#include <string>
using namespace std;
int main()
{
char text[16];
char ans, var;
cout << "Welcome TO SonniE's Text To Hex! A WWW.codinghs.COM Original\n";
here:
var = 0;
cout << "Enter Your Text: ";
std::cin>>text;
std::cout << "Text: "<< text <<"\nHexadecimal Value: ";
do{
cout<< hex << int(text[var]);
var++;
}while (text[var] != '\0');
cout<< "\n";
system("PAUSE");
cout << "Do You Want To Convert Another Character? (y/n)";
cin >> ans;
if (ans == 'y' || ans == 'Y')
{
system("cls");
goto here;
}
else
{
system("pause");
}
return 0;
}

Heres An Example of this app in action


Welcome TO SonniE's Text To Hex! A WWW.codinghs.COM Original
Enter Your Text: SonniE
Text: SonniE
Hexadecimal Value: 536f6e6e6945

WhoIsYou
06-03-2008, 02:18 AM
Neat app, could be useful. +REP (if i can now....)

Jet.HaCkR
06-16-2008, 02:30 AM
Nice Man i gotta start learning C++

MAD Industries
06-26-2008, 06:32 PM
it apparently does not like spaces. nice job though

Scruffy120
06-28-2008, 01:55 PM
^haha i was gunna post about the spaces to...ya beat me to it

SilverSurfer
07-01-2008, 12:58 AM
hows about a hex to decimal converter..


eg:

#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

int main( void )
{
string prompt = "Enter a hex value to convert, 0 to exit\n>";
int val;

do
{
cout << prompt;
cin >> hex >> val;
cout << "\n" << hex << val << " -> " << dec << val << "\n";
} while( val );

return 0;
}

WhoIsYou
07-02-2008, 08:10 AM
lol, this is all confusing

What's there to be confused about?

SonniE
07-03-2008, 02:40 PM
hows about a hex to decimal converter..


eg:

#include <iostream>
#include <iomanip>
#include <string>

using namespace std;

int main( void )
{
string prompt = "Enter a hex value to convert, 0 to exit\n>";
int val;

do
{
cout << prompt;
cin >> hex >> val;
cout << "\n" << hex << val << " -> " << dec << val << "\n";
} while( val );

return 0;
}
nice job silver i might play with ur style later