Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How can I read binary files?

Status
Not open for further replies.

Bertv100

Programmer
Apr 27, 2000
204
BE
Hi all,

As the title of this question already suggested, I would like to know how to read (and write) binary files (aka record files) using g++. I can already read and write text files using
Code:
ifstream
and
Code:
ofstream
, but, since these work with streams, they might have a little problem with special characters.

Thanks in advance! Regards,
Bert Vingerhoets
vingerhoetsbert@hotmail.com
Don't worry what people think about you. They're too busy wondering what you think about them.
 
You can open your stream with ios::binary ORed into the flag list to open files in binary mode.

That said, binary mode on a UNIX computer is no different from text mode. The only place it matters is on a Windows or Mac machine, where binary and text files are treated differently.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top