How do i save data?

B

bballmitch

for example, i made falling numbers and i'd like to keep track of high
scores, and for the program to remember the high scores when i close
and reopen the program. How do i do that?
 
R

Rolf Magnus

bballmitch said:
for example, i made falling numbers and i'd like to keep track of high
scores, and for the program to remember the high scores when i close
and reopen the program. How do i do that?

Write it to a file. Have a look at the ifstream and ofstream classes.
 
R

Raf256

for example, i made falling numbers and i'd like to keep track of high
scores, and for the program to remember the high scores when i close
and reopen the program. How do i do that?

Write to a file, like
ofstream scoreFile("scores.txt");
scoreFile<<1<<"\n"<<2<<endl;
scoreFile.close();

include <fstream> and make the code above using namespace std;
 
B

benben

Besides saving it to a file as many has suggested, you also can

1. Write it to a database if you have a connection to one
2. Pass it to another program which remains running until your program
reopens
3. Output it to a certain device (tape recorder, floppy, etc)
4. Write it to the registry if you are running on windows
5. Tell the user to write down the data by hand and when the program
reopens prompt the user for that
6. Save it to a cookie if your program is a web application.
7. Email the data to a specific mailbox and retrieve it as the program
reopens.

Have fun!

Ben
 
L

Lars Weber

bballmitch said:
Will that work with OpenGL as well?

Sure. OpenGL is just another framework.

You should read this:
http://nehe.gamedev.net/

He has great tutorials on the left side of the webpage.
If you're not that deep into programming, then this will be a good start.

Have fun,
Lars
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,431
Messages
2,571,677
Members
48,796
Latest member
Greg L.

Latest Threads

Top