Review your favorite Linux distribution.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 11-26-2005, 10:28 PM   #1
Registered: Dec 2004
Location: Russia, Siberia, Kemerovo
Distribution: Slackware
Posts: 893

Rep: Reputation: 35
Binary reading/writing in cpp

How will this look in cpp:
FILE *f;
fwrite (&version, sizeof (MapVersion), 1, f);
fread (&version, sizeof (MapVersion), 1, f);

I know that I can use c in cpp, but I want to know how to do binary reading/writing in cpp.

Old 11-27-2005, 07:09 PM   #2
Senior Member
Registered: Mar 2005
Location: USA::Pennsylvania
Distribution: Slackware
Posts: 1,065

Rep: Reputation: 45
>> I want to know how to do binary reading/writing in cpp.

I have never needed to use it, but there is a binary flag in IOS....

so it would probably be somthing like

ofstream outfile ("out.bin", ios:: out | ios::app | ios::binary);
ifstream infile ("in.bin", ios::in | ios::binary | ios::ate);
you should search on streams before using this as I never have


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Reading binary files on CDROM dwforslund Linux - General 2 09-29-2005 05:39 PM
problem in reading Microsoft word as a binary file ljqu_happy Programming 15 02-02-2005 10:10 AM
Reading Memory Value from ELF Binary Damaged Soul Programming 4 11-24-2004 11:52 PM
Problems with reading back serial binary data esi-eric Linux - Software 14 08-06-2004 01:48 PM
Problem in reading/writing binary data in Linux esi-eric Linux - Hardware 3 07-20-2004 04:21 PM

All times are GMT -5. The time now is 10:17 PM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration