• Advertisement

Archived

This topic is now archived and is closed to further replies.

Saving and opening files in a game...

This topic is 5308 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How does the Open and Save work..if i am in a game and i save my game what/how does it save?.. and when im opening it how does it do that?

Share this post


Link to post
Share on other sites
Advertisement
I think you mean binary files so you should look up these functions.. fread() fwrite()...to make things easier go here there''s the definitions to the functions you want

Share this post


Link to post
Share on other sites
Or you could use some c++ objects for in/output.

int the header

there are: std::ifstream and std::ofstream.

//For output, just create an ofstream object.
std::ofstream MyFile;
//then open the file
MyFile.open("MySuperCoolFile.txt");
//then write things to it:
MyFile << "I am sooo coool\n";
//then close the file
MyFile.close();


So, all done, now just look in "MySuperCoolFile.txt" on your disk and see if anything happend! :-)

----------------------------------------------
Petter Nordlander

"There are only 10 kinds of people in the world. The who understand binary and those who don''t"

Share this post


Link to post
Share on other sites
When I save stuff I usually declare a struct with variables that hold the data I want to save. Then I just copy the entire struct (binary mode) to a file using the write() and read() method from std::ofstream and std::ifstream.

Share this post


Link to post
Share on other sites

  • Advertisement