954,498 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Saving Data For Next Startup

I figured out how to use time in C since the last time I asked a question here. :cool:
My new dilemma is that I was wondering if its possible to save user input in a C program so that when the program is closed and executed again it will still have that data stored such as:
If Jan checks in for work but is late, the program adds 1 to his late days so that it is now 4 but after being shut down for the night and rebooted next day when it executes again the number of late days for Jan is still 4.

If it can be done can you generally tell me how so I can look it up?

sketchiii
Newbie Poster
8 posts since Jan 2011
Reputation Points: 10
Solved Threads: 0
 

Save the data to file.

gerard4143
Nearly a Posting Maven
2,272 posts since Jan 2008
Reputation Points: 512
Solved Threads: 387
 
Save the data to file.


Like to a normal file thats not related to C? I'll look it up thanks but is there a way to do it using C only?

sketchiii
Newbie Poster
8 posts since Jan 2011
Reputation Points: 10
Solved Threads: 0
 
... but is there a way to do it using C only?

C programs execute in memory. Once that process' memory is unloaded (i.e. the program exits) the values stored there are no longer valid. You can do several things to create persistent memory - which you choose depends on your needs.Use a lightweight database
Use a file
Use a system facility (Windows registry)
Run a process that manages the values and register with that[1]
[1] Of course, this approach requires you to eventually store the data when it exits. This would be something like a daemon in UNIX or a service in Windows.

L7Sqr
Practically a Master Poster
657 posts since Feb 2011
Reputation Points: 201
Solved Threads: 124
 

Ok Thanks for clearing that up.

sketchiii
Newbie Poster
8 posts since Jan 2011
Reputation Points: 10
Solved Threads: 0
 

This question has already been solved

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: