Saving variables using a text file?

Non-platform specific questions.

Saving variables using a text file?

Postby Hblade » Fri Oct 21, 2011 8:22 pm

I seen some people able to make level engines and save it to a text file.. how is this done O-o
Code: Select all
[0][1][0][0][0][0]
[0][1][0][1][0][1]
[0][1][0][0][1][0]


Stuff like that.
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score

Re: Saving variables using a text file?

Postby skydereign » Fri Oct 21, 2011 9:42 pm

You use file io, so functions like fprintf and fscanf. You can use others as well, but I think those are the ones you'd be familiar with. There are plenty of posts about them, you use fopen to get a FILE*, and then use fprintf (acts like sprintf) and with two for loops you print out the data. Then do the reverse with fscanf. Again there are examples on the forums (searching fopen/fprintf/fscanf should do the trick), but if you need more instruction do ask.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Saving variables using a text file?

Postby Hblade » Fri Oct 21, 2011 10:33 pm

Thanks sky. =)
Subscribe to my YouTube? - Yes| No
User avatar
Hblade
 
Posts: 4455
Joined: Fri Dec 08, 2006 11:14 pm
Score: 181 Give a positive score


Return to General

Who is online

Users browsing this forum: No registered users and 1 guest