I am trying to make a bank C++ program but the problem is that when the program terminates, data is lost and when I start it again, it reinitializes. Can someone tell me how to save the information in my harddrive and not my RAM?

Well You should use files to store data and get back data in the beggining stages.

filestreams would help you out with that.

Try googling out filestreams with c++ for a tutorial.

There are several ways...

The most popular way would be to save the information to a file then retrieve it later.

Another popular way that isn't done unless absolutely necessary is by querying information to a database then retrieving it later.

There may be a way to fool around with memory and store the information somewhere more permanent, but I don't know how to do that, nor would I recommend it.

There may be a way to fool around with memory and store the information somewhere more permanent, but I don't know how to do that, nor would I recommend it.

Yeah, it's usually called "copying contents of memory to a disk file in some format" :lol:

There are some types of memory more enduring than RAM (eg ROM) but using them relies on them being present (i.e. not guaranteed to be available for use on all computers) and also relies on significantly more knowledge than saving data to a disk file.

Yeah, it's usually called "copying contents of memory to a disk file in some format" :lol:

There are some types of memory more enduring than RAM (eg ROM) but using them relies on them being present (i.e. not guaranteed to be available for use on all computers) and also relies on significantly more knowledge than saving data to a disk file.

Yes that's pretty much the point I was getting at, besides the other 2 more reliable (and safer) ways I've already mentioned.

Hi
like sbdy told u above search for

filestreams

but when u start searching for tutorials add the following term as well:

serialization

A hard disk and thus a disk file too has a one-dimensional structure -> linear.
Therefore whenever you write to a file, you write one thing after another--serially.
Hence the name serialization. The opposite is called deserialization.

Finally u might find helpful the following thread which is also about a bank account program and uses serialization:
http://www.daniweb.com/forums/thread151845-2.html

I am starting to suspect that u and Avaviel might be classmates.... :D :D :D

This article has been dead for over six months. Start a new discussion instead.