70,021
社区成员




FILE *file = fopen("TempRecord.txt","w");
FILE *logfile = fopen("CountHour.txt","a+");
if(file == NULL)
{
strcat(buf,"Open temporary file error ! \r\n");
fprintf(logfile,"%s",buf);
return -1;
}
if(logfile == NULL)
{
strcat(buf,"Open log file error ! \r\n");
fprintf(logfile,"%s",buf);
return -1;
}
strcat(buf,"tashan will stop,begin write last number into logfile ! \r\n");
fprintf(logfile,"%s",buf);
fgets(num,10,file);
sscanf(num,"%d",&curentNum);
curentNum = g_nBroadNum;
fprintf(file,"%d",curentNum);
fclose(logfile);
fclose(file);
fprintf(logfile,"%s",buf);
fgets(num,10,file);
sscanf(num,"%d",&curentNum);
curentNum = g_nBroadNum;
fprintf(file,"%d",curentNum);
file = fopen("TempRecord.txt","r");
logfile = fopen("CountHour.txt","a+");
if((file == NULL) || (logfile == NULL))
{
return -1;
}
strcat(buf,"tashan is start,begin read logfile ! \r\n");
fprintf(logfile,"%s",buf);
fgets(num,10,file);
sscanf(num,"%d",&curentNum);
g_nBroadNum = curentNum;
fprintf(logfile,"Broad date current is %d\r\n",curentNum);
fclose(logfile);
fclose(file);
return 0;
if(logfile == NULL)
{
strcat(buf,"Open log file error ! \r\n");
fprintf(logfile,"%s",buf);//文件不能打开为什么还望文件中写数据~
return -1;
}