DaniWeb IT Discussion Community

DaniWeb IT Discussion Community (http://www.daniweb.com/forums/index.php)
-   C++ (http://www.daniweb.com/forums/forum8.html)
-   -   C++ computer memory access (http://www.daniweb.com/forums/thread152077.html)

sohamghosh Oct 19th, 2008 1:31 am
C++ computer memory access
 
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?

Sky Diploma Oct 19th, 2008 1:34 am
Re: C++ computer memory access
 
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.

Alex Edwards Oct 19th, 2008 1:36 am
Re: C++ computer memory access
 
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.

grumpier Oct 19th, 2008 1:45 am
Re: C++ computer memory access
 
Quote:

Originally Posted by Alex Edwards (Post 715906)
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.

Alex Edwards Oct 19th, 2008 1:48 am
Re: C++ computer memory access
 
Quote:

Originally Posted by grumpier (Post 715911)
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.

sidatra79 Oct 19th, 2008 12:38 pm
Re: C++ computer memory access
 
Hi
like sbdy told u above search for

Quote:

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

Quote:

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


All times are GMT -4. The time now is 11:55 pm.

Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2009 DaniWeb® LLC