|
#include <stdio.h>
#include <time.h>
#include <windows.h>
struct timer
{
int hour;
int minite;
int second;
} t;
int main ()
{
FILE * fp;
if (NULL == (fopen ("f:\\timeRed.txt", "r")))
{
printf ("Get the file Failed!");
exit (1);
}
fread (&t, sizeof (struct timer), 1, fp);
while (1)
{
rewind (fp);
Sleep (1000);
fread (&t, sizeof (struct timer), 1, fp);
if (t.second == 59)
{
t.minite = t.minite + 1;
if (t.minite == 60)
{
t.hour = t.hour + 1;
}
t.second = 0;
}
else
t.second ++;
printf ("% d% d% d", t.hour, t.minite, t.second);
fwrite (&t, sizeof (struct timer), 1, fp);
fclose (fp);
}
}
When running under Vc, there is a problem of ms memory error ~~~ expert advice! |
|