Archived

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

TheNerd Tk421

Saving and opening files in a game...

Recommended Posts

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