I'm new to C++ std::stream and I'm making some tests. I have this simple code:
int i = 10;
char c = 'c';
float f = 30.40f;
std::ofstream out("test.txt", std::ios::binary | std::ios::out);
if(out.is_open())
{
out<<i<<c<<f;
out.close();
}
As the stream is opened as std::ios::binary
I expect in the test.txt
file to have the binary representation of i
, c
and f
, but instead I have 10c30.4
.
Can you please tell me what I'm doing wrong?
See Question&Answers more detail:os