After performing a fread and populating the data array I can successfully dump it's contents as hex to the console window. However, when I attempt to dump just the raw data the .exe crashes, I don't understand why.
1 2 3 4 5
for ( i = 0; i < size; ++i )
{
printf("%02X ", data[i]); // Works.
printf("%S", data[i]); // Crashes.
...
I've tried other things like: printf("%S", (char)data[i]); but without success.
What's the difference that it doesn't like string but will format as hex?
The problem is because data[i] is not a Cstring, it is a character, so when you attempt to print it as a Cstring, printf() simple acts like it is a char* and accesses basically random memory, causing a crash.