I'm trying to write a text based game using C. To do this the way I want, I need to include a save system that will output all of the necessary variable values to external files, then be able to load the values fro those files later. Any advice?
Nicholas_1 0 Newbie Poster
Recommended Answers
Jump to PostTake a look at
http://www.cprogramming.com/tutorial/cfileio.html
for file IO in C. It is relatively straightforward, but feel free to post here again with questions that you may have.
Jump to PostI'd recommend writing the value of the variables to a text file, and tag each value with the name of the variable. That way you can change the program to add more or remove some variables without changing the format of the file. An old *.ini file format is good …
Jump to Post
fprintf(file, "%d""%s" , array[i], " ");
Why %s when all you want is a space
fprintf(file, "%d " , array[i]);
All 11 Replies
deceptikon 1,790 Code Sniper Team Colleague Featured Poster
Nicholas_1 0 Newbie Poster
deceptikon 1,790 Code Sniper Team Colleague Featured Poster
Nicholas_1 0 Newbie Poster
deceptikon 1,790 Code Sniper Team Colleague Featured Poster
Nicholas_1 0 Newbie Poster
linux 107 Posting Shark
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Nicholas_1 0 Newbie Poster
Ancient Dragon 5,243 Achieved Level 70 Team Colleague Featured Poster
Nicholas_1 0 Newbie Poster
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.