I'm trying to print out the following 128-bit value as a sequence of 8-bit values in hexadecimal:
The function I'm using to print the values:Code:unsigned int MDBuffer [4] = {0x01234567, 0x89abcdef, 0xfedcba98, 0x76543210};
This produces the output:Code:void printOutput() { unsigned char * outChars = (unsigned char*) &MDBuffer; for(int i = 0; i<16; i++) { printf("%02x " , *(outChars+i) ); } cout<<"\n"; }
67 45 23 01 ef cd ab 89 98 ba dc fe 10 32 54 76
I'm not sure what is happening to produce this output...
My only guess is that it relates to the 'endianess' of the values, and that my function is printing them 'backwards'.
Is this guess along the right lines, or am I making some other mistake? What could I do to correct this bug?
I'm currently researching the whole topic of endianess in C++, but it's all pretty much over my head! So any help would be greatly appreciated.![]()




Reply With Quote