1

i tried to convert the string to ASCII but couldn't convert the ASCII to hex

#include <stream>
#include <string>
using namespace std;
int main()
{
    string x="hello";
    string x_as_cii[10];
  for(int i=0;i<x.length();i++)
  {
      x_as_cii[i]= int(x[i]);
      cout<<x_as_cii[i]<<endl;
   }
return 0;


}

Reham
  • 115
  • 1
  • 8
  • What exactly do you mean by "ascii to hex"? The ascii string you have shouldn't convert to hex, as there is no "h", "l", or "o" in the hex character set. Maybe I'm missing something? –  Oct 17 '19 at 21:17
  • firstly thank you for your reply secondly my problem is i have string that i wanted to convert it to hexadecimal so i could XOR it with another string "Vernam cipher problem" so i tried to convert each char to its ascii code but i couldn't convert the ascii to hex so if u have any ideas i could try i would be thankful – Reham Oct 18 '19 at 10:32

1 Answers1

0

Boost.Algorithm has boost::hex (and the inverse boost::unhex), which should do what you want.

Marshall Clow
  • 15,972
  • 2
  • 29
  • 45