|
#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);
}
}
在Vc下运行就出现ms内存错误问题~~~高手指点下! |
|