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?

7 Years
Discussion Span
Last Post by sketchiii

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?


... 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.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.