计算开机时间
程序代码:
#include<stdio.h> #include<conio.h> #include<windows.h> struct time { int hour; int minute; int second; }t; int main(int argc,char *argv[]) { FILE *fp; fp=fopen("Time","r"); fread(&t,sizeof(struct time),1,fp); while(!kbhit()) { rewind(fp); Sleep(1); fread(&t,sizeof(struct time),1,fp); if(t.second==59) { if(t.minute==60) { t.hour=t.hour+1; t.minute=0; } t.second=0; } else t.second=t.second+1; printf("%d:%d:%d\n",t.hour,t.minute,t.second); fp=fopen("Time","w"); fwrite(&t,sizeof(struct time),1,fp); fclose(fp); } return 0; }问题是正确编译链接 结果出错