Convert a string to Hexadecimal ASCII values | GeeksforGeeks

preview_player
Показать описание
Our courses :

This video is contributed by Anant Patni

Please Like, Comment and Share the Video among your friends.

Install our Android App:

If you wish, translate into the local language and help us reach millions of other geeks:

Follow us on Facebook:

And Twitter:

Also, Subscribe if you haven't already! :)
#geeksforgeeks
Рекомендации по теме
Комментарии
Автор

Solution in C++

String intToHex(int num, string part);
Int main()

String ascii = " hello ";
String hex = " ";
String part;
Int dec;
char character;


for(int i = 0; i < ascii.size(); i++)
{
ch = ascii.at(i);
num = int(ch);
part = intToHex(num, part);
Revese(part.begin(), part.end();
Hex = hex + part;
}
Cout << hex << endl;

return 0;

String intToHex( int num, string part)
{
int mod;
Int j =0;
char hex2[50];

While( num > 0)
{
mod = num% 16;
If (mod < 10)
{
hex2[j] = mod + 48;
j++;
}
else
{
hex[j] = mod + 55;
}
num = num/ 16;

part = hex2;
return part;
}

Noah-
Автор

Personally, I want to convert from hexadecimal which appears in my serial output like this: 50 4F 57 45 52 31 20 31 to HEX - ASCII (TASMOTA BERRY CODE) so that it shows me POWER1 1 and the TASMOTA relay is activated via TX - RX . Is there any way?

JohnKourdomenos
Автор

May you please help me to understand string of game.
I have string text of (ADAM COLE) in game string file and game hex string for this string text is 29 23.

messiahmoddingstudio