File isn't saved when Windows shuts down

I wrote a program in C for my laptop to see how long the battery will last. As soon as the laptop goes to battery operation, it writes the start time(when the laptop went to battery) and current time to a file, then closes that file, and writes the same thing to another file then closes that file. It alternates between the two files continuously until the computer shuts off by itself. I used two files so that when the computer shuts down, one file was guaranteed to be written to and closed.
What I found was that if the battery lasted 2 hours, when I opened the files, I found that the last write was around 30mins before the computer actually shut down. Why would that be? What is Windows doing that the last half hour, or so, of writes was lost? Is there something I can do to force Windows to remember the last save?

Pete S - Tucson, AZ

Comments

  • SephirothSephiroth Fayetteville, NC, USA
    : I wrote a program in C for my laptop to see how long the battery will last. As soon as the laptop goes to battery operation, it writes the start time(when the laptop went to battery) and current time to a file, then closes that file, and writes the same thing to another file then closes that file. It alternates between the two files continuously until the computer shuts off by itself. I used two files so that when the computer shuts down, one file was guaranteed to be written to and closed.
    : What I found was that if the battery lasted 2 hours, when I opened the files, I found that the last write was around 30mins before the computer actually shut down. Why would that be? What is Windows doing that the last half hour, or so, of writes was lost? Is there something I can do to force Windows to remember the last save?
    :
    : Pete S - Tucson, AZ
    :
    Chances are it went into hybernate mode to be safe. In this mode no apps run so your app was dead.

    -[italic][b][red]S[/red][purple]e[/purple][blue]p[/blue][green]h[/green][red]i[/red][purple]r[/purple][blue]o[/blue][green]t[/green][red]h[/red][/b][/italic]

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion