Page 1 of 1

Saving variables using a text file?

PostPosted: Fri Oct 21, 2011 8:22 pm
by Hblade
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.

Re: Saving variables using a text file?

PostPosted: Fri Oct 21, 2011 9:42 pm
by skydereign
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.

Re: Saving variables using a text file?

PostPosted: Fri Oct 21, 2011 10:33 pm
by Hblade
Thanks sky. =)