So I've been setting an fstream class with openmode as binary and reading info to it, as in the following example:
1 2 3
fstream file("foo.txt",ios_base::out|ios_base::binary);
int i = 1024;
file << i;
Now I would've expected to see, in foo.txt, the binary representation of 1024. But I keep getting the text of '1024'. Am I wrong in one of my assumptions, or am I just doing something wrong? Thanks in advance!
Yes, your assumptions are wrong. The << and >> operators are for formatted I/O. If you just want to handle raw data (binary data), you must not use them.