1234567891011
std::ostringstream msg; msg.str(""); unsigned char value = 'F'; unsigned char *data; data = &value; msg<< "Data: " << endl << std::internal << std::setw( 8 ) << std::setfill( '0' ) << std::uppercase << hex << *reinterpret_cast< unsigned int*>(data) << "\t -\t " << std::dec << *reinterpret_cast<unsigned int*>(data);
Data : 0x00000046 - 70
Data : 0xCCCCCC46 - 3435973702
#include <iostream> #include <iomanip> int main() { unsigned char value = 'F' ; unsigned char *ptr = &value ; std::cout << std::hex << std::showbase << std::internal << std::setfill('0') << std::setw(10) << int(*ptr) << "\t - \t" << std::dec << int(*ptr) << '\n' ; }