開發平台(Platform)(Ex: Win10, Linux, ...) 編譯器(Ex: GCC, clang, VC++...)+目標環境(跟開發平台不同的話需列出)
GCC
問題(Question):
我設計一個程式每秒去檢查某檔案是否存在
每10秒顯示目前經過秒數
預期的正確結果(Expected Output):
每秒顯示一次資訊
錯誤結果(Wrong Output):
10秒才一次性顯示全部資訊
程式碼(Code):(請善用置底文網頁, 記得排版)
int main(){
FILE *fid_rd;
int count=0,accu=0;
while(1){
fid_rd=fopen(".running","r");
sleep(1);
if(!fid_rd){
printf("finish\n");
break;
}else{
printf(".");
if(count==9){
count=0;
accu+=10;
printf("Simulator has took %d secs\n",accu);
}else
count++;
fclose(fid_rd);
}
return 0;
}