Binary File IO with ofstream - TechRepublic
General discussion
October 17, 2000 at 06:51 AM
dfarrell

Binary File IO with ofstream

by dfarrell . Updated 25 years, 7 months ago

Hi,
I’m trying to write binary data to an ofstream object and I’m doing this :

long MyInt = 1234;
MyFile << MyInt << std::flush; This works but the file contains the string "1234", not the binary representation of the long value. I've opened MyFile with ios::binary, but that doesn't seem to be the trick. How do I write to this file so it contains the actualy binary representation of a long variable? Thanks in advance, Doug Farrell

This discussion is locked

All Comments