LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
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, 10: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, 07: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



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
Problems with reading back serial binary data esi-eric Linux - Software 15 10-03-2018 09:13 AM
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
Problem in reading/writing binary data in Linux esi-eric Linux - Hardware 3 07-20-2004 04:21 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 11:15 PM.

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
Open Source Consulting | Domain Registration