![](/img/trans.png)
[英]How to write a script to run a program multiple times and store the time in a file?
[英]How to write to a file multiple times in C?
我正在编写一个C文件,可以将执行时间输出到一个csv文件中。 而且我还想每次运行可执行文件时将结果写入相同的csv文件。 我使用的是普通的I / O格式,我将使用命令行传递相同的输出文件名。
int main(int argc, char**argv) {
outFile = fopen(fileName,"w+");
fprintf(outFile, "%d, %f\n",numbers,time_spent);
fclose(outFile);
return 0;
}
每次打开文件时, fopen()
都会删除当前内容。 有没有一种方法可以打开文件而不删除内容?
使用fopen(fileName, "a+");
代替。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.