贬义成可执行文件是出现了一个错误,知道是函数除了问题,但不知道具体是那个,求解
#include<stdio.h>#include<windows.h>
struct time
{
int hour;
int minute;
int second;
}t;
main()
{
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)
{
t.minute+1;
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);
}
}这个编程的功能是记录开机的时间
sleep(1); 改为 Sleep(1);
t.minute+1; 改为 t.minute++;
t.hour==t.hour+1; 改为 t.hour++; “==”使用来判断的
kbhit() 改为 _kbhit()
添加 #include <conio.h>
一般头文件不知道是哪个,查询下 msdn 就可以了
页:
[1]