Problem with ostream::put

I'm trying to write some binary data to file. Tried to do it part by part with put, with write and all at once with write but every time it goes like this:
1
2
3
4
5
6
ofstream target
target.open(filename.c_str(), ios::binary);
  unsigned char a=0xFF;
  target.put(a); // writes D1 8F to file instead of FF
  unsigned int b=36466100;
  target.write((char*)&b,4); // becomes d2 91 6d 2c 02  instead b4 6d 2c 02   

Bytes lower than 0x80 are ok, but can't write higher ones.

How to write it the way I want?
Last edited on
First of all, pir() fuction is not overloaded for signed and unsigned character types. This might be the cause of error.

Otherwise code is correct and should work. (It actually works for me)
Today i tried diffrent IDE and compiler (before one with TDM-GCC 4.8.1, now MiniGW 3.4.2) and it works fine.
Last edited on
Topic archived. No new replies allowed.