LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
Search this Thread
Old 11-26-2005, 11:28 PM   #1
kornerr
Member
 
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:
Code:
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.

Thanks.
 
Old 11-27-2005, 08:09 PM   #2
xhi
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

Code:
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
 
  


Reply


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 06:39 PM
problem in reading Microsoft word as a binary file ljqu_happy Programming 15 02-02-2005 11:10 AM
Reading Memory Value from ELF Binary Damaged Soul Programming 4 11-25-2004 12:52 AM
Problems with reading back serial binary data esi-eric Linux - Software 14 08-06-2004 02:48 PM
Problem in reading/writing binary data in Linux esi-eric Linux - Hardware 3 07-20-2004 05:21 PM


All times are GMT -5. The time now is 08:25 AM.

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