I try to write 32bit integers to file using an ostream. I'm using the << operator:
ostream file;
map<unsigned char, int32_t> histogram;
//…
file << reinterpret_cast<char*>(&histogram[i]);
It works well except for the last number (in my case 11328 which would be 40 2C 00 00 in binary) but instead only 40 2C is written into the file.
It is the same number but when I'm going to import the file again I want to asume that every number is coded in 32bit.
What did I do wrong?