Jump to content
  • Advertisement


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

TheNerd Tk421

Saving and opening files in a game...

This topic is 5524 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

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
//then write things to it:
MyFile << "I am sooo coool\n";
//then close the file

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

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!