opening a binary file into hexadecimal

Hey,

I have some data encoded in binary little endian format. I would like to convert it to hexadecimal format, as can be done by unix with the command hexdump.

Does anyone know if there is a way of doing so using c++ ?

Thanks a lot.
Just read the byte(s) from the file, and print them as hex:

1
2
3
uint8_t val;
file.read(&val,sizeof(uint8_t));  // read 1 byte from the file
cout << hex << setw(2) << setfill('0') << int(val);  // print it as 2-digit hex 
Topic archived. No new replies allowed.