Page 1 of 1

Binary files in C?

PostPosted: Sat Oct 27, 2012 11:35 pm
by SuperSonic
I know that in C++, you can use fstream objects to read and write binary files using the corresponding read(char*, int) and write(char*, int). Are there functions in C that do the same things for FILE objects, or do I have to build them myself? :D

Re: Binary files in C?

PostPosted: Sun Oct 28, 2012 1:15 am
by skydereign
You can open files in binary mode by adding a b to the mode. And you can use the fwrite and fread function to write out variables.

Re: Binary files in C?

PostPosted: Sun Oct 28, 2012 3:05 am
by SuperSonic
Ok, that's right. Sorry, I got so used to C++ that I forgot how to do it in C :roll: