-
April 21st, 2000, 02:09 PM
#1
How do I read binary data files ?
I need convert the read data in int, int8, int16 or short, int32 or long and int64.
I use
int fgetc( FILE *stream );
wint_t fgetwc( FILE *stream );
but this function only read int8 and short. Regard
-
April 21st, 2000, 02:32 PM
#2
Re: How do I read binary data files ?
The way I normally do it is use the fstream class as follows:
fstream fileStrm;
fileStrm.open(czFileName,ios::in | ios:ut | ios::binary);
int myInt;
float myFloat;
short myShort;
fileStrm.read((char*)&myInt,sizeof(myInt));
fileStrm.read((char*)&myFloat,sizeof(myFloat));
fileStrm.read((char*)&myShort,sizeof(myShort));
If you look up the documentation for fstream::read, the arguments are very straight forward.
Hope that helps.
-
May 2nd, 2001, 09:14 PM
#3
Re: How do I read binary data files ?
Hey,
Can we use >> and << to input and output a
binary file?
Thanks.
Warren
-
May 4th, 2001, 01:42 PM
#4
Re: How do I read binary data files ?
Dave Volland
That which does not kill us makes us stronger. Or smarter.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|