Trying to figure out how to read in data from a binary file one byte at a time, then display it in hex. From my googling, I've figured out this much, but when I cast it to an int, it displays the hex values as 4 bytes instead of 1 (so ff is ffffffff). I want it to only display as one byte, and I'd also like it to be in all caps. Anyone know how?
It says "invalid conversion from 'unsigned char*' to 'std::basic_istream<char>::char_type* {aka char*}'" when using an unsigned char.
When I cast it to signed char it says "invalid static_cast from type 'unsigned char [10]' to type 'char'|" and if I use a c-style cast it says "cast from 'unsigned char*' to 'char' loses precision"
The error seems to say you're trying to cast an unsigned char[] to signed char. Is that the case?
You said to use unsigned chars, and that I'd have to cast them to signed while reading in from the file. That's what I was trying to do.
cout << hex << static_cast<unsignedint>(static_cast<unsignedchar>(data[i])) << " ";
This seems to work, although it seems... unusual. Is it okay to do that?
Edit: Oh wait, that's what L B meant by nest casts?