运行就崩溃
各位大神,不知道是哪里有问题,求指正#include <stdio.h>
#include <conio.h>
#include <windows.h>
struct time
{
int hour;
int minute;
int second;
}t;
main()
{
FILE *fp;
fopen("time","r");
fread(&t,sizeof(struct time),1,fp);
while(!kbhit())
{
Sleep(1);
if(t.second==59)
{
t.minute++;
t.second=0;
if(t.minute==59)
{
t.hour++;
t.minute=0;
}
}
else
t.second++;
printf("累计开机时间为:%d:%d:%d\n",t.hour,t.minute,t.second);
fp=fopen("time","w");
fwrite(&t,sizeof(struct time),1,fp);
fclose(fp);
}
}