char[] problem
Hello. I've always wondered how they print the hex equivalent of a certain array of characters side by side..
Like for example, I have an array of characters with size x:
char[x];
then I would like to print both its string and hex equivalent side by side with 4 elements per line. For example:
H0 P6 S1 21 00 || A B C D E
and so on and so forth...
Any ideas on how this can be done?
[443 byte] By [
rba1988] at [2007-11-20 10:51:16]

# 1 Re: char[] problem
I must be missing something here... what are H0, P6, and S1? Otherwise you should take a look at the iomanip header, especially the hex function.
Cheers,
Zen
# 2 Re: char[] problem
Hello. I've always wondered how they print the hex equivalent of a certain array of characters side by side..
Like for example, I have an array of characters with size x:
char[x];
then I would like to print both its string and hex equivalent side by side with 4 elements per line. For example:
H0 P6 S1 21 00 || A B C D E
and so on and so forth...
Any ideas on how this can be done?
H P S are not hex characters but usually you can loop through the array and do a
sprintf(temp, "%02X", array[i]);
# 3 Re: char[] problem
I must be missing something here... what are H0, P6, and S1? Otherwise you should take a look at the iomanip header, especially the hex function.
Cheers,
Zen
They aren't...they're just examples. hehe
For example, I have these hexes:
4e094 4e095 4e096 4e097 4e098 4e099 4e09a
They have corresponding character equivalents (printable and non-printable chars)
I want to arrange them in such a away that it appears this way in the console:
4e094 4e095 4e096 4e097 A B C D
4e098 4e099 4e09a E F G
# 4 Re: char[] problem
K, did the hex function help at all? You'll also have to keep in mind that you must cast your chars to unsigned int, otherwise they'll only display as characters.
# 5 Re: char[] problem
K, did the hex function help at all? You'll also have to keep in mind that you must cast your chars to unsigned int, otherwise they'll only display as characters.
Yep...I know how to use the sprint function..got it working...all I need to do now is get both arrays side by side...so far I can only do
HEx Array
Char array
I have to do:
Hex Array Char Array
with 4 elements per array so that's 8 per line