char buffer[128];
// read in buffer
// now buffer contains some string
int len = strlen(buffer);
char hex[4];
memset(hex,0,4);
for(int i = 0;i<len;i++)
{
sprintf(hex,"%x",buffer[i]);
// hex now contains the string equiv of the hex value
}
//if you just want to output in hex
cout<<hex<<buffer[i]<<endl;
could replace the sprintf
In actuallity, the decimal value is hex which is binary which is octal. You just need to know the conversions for the different representations.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.