我正在尝试制作一个秒表程序,该程序将czas
写入file.txt
. 我今天开始学习C,所以请原谅我,如果这是一个愚蠢的问题,但编译器不会抛出任何错误,NetBeans也不会显示任何感叹号。有我的代码:
#include <windows.h>
#define sleep(x) Sleep(1000 * x)
#include <stdio.h>
#include <stdlib.h>
int a = 0;
int czas = 0;
int main (void)
{
FILE *file;
while (a < 30) { /*repeats only 30 times*/
a = a + 1; /*increases the counter for while loop*/
file = fopen("file.txt","w"); /*opens file.txt for writing*/
fprintf(file,"%s", czas); /*writes czas to file.txt*/
fclose(file); /*closes file.txt to save*/
czas = czas + 1; /*increases czas for writing to file*/
}
return 0;
}
有人可以帮我吗?