Binary files in C?

You must understand the Game Editor concepts, before post here.

Binary files in C?

Postby SuperSonic » Sat Oct 27, 2012 11:35 pm

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
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score

Re: Binary files in C?

Postby skydereign » Sun Oct 28, 2012 1:15 am

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.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Binary files in C?

Postby SuperSonic » Sun Oct 28, 2012 3:05 am

Ok, that's right. Sorry, I got so used to C++ that I forgot how to do it in C :roll:
A tree never hits an automobile except in self-defence.

Want to use your joystick or controller with Game Editor? Check out my controller engine =D
User avatar
SuperSonic
 
Posts: 1443
Joined: Fri Sep 24, 2010 9:24 pm
Location: Anywhere
Score: 72 Give a positive score


Return to Advanced Topics

Who is online

Users browsing this forum: No registered users and 1 guest

cron