【发布时间】:2013-09-27 15:22:08
【问题描述】:
到目前为止,我只使用 Linux 进行编码(基本上是 gcc 和 Kate 的命令行)。我想在 Windows 中编程,因为我可以访问所有更强大的机器来运行 Win7。
所以我下载了代码块和 minGW。 Hello world 运行良好,但在打印要归档的内容时,它只会给我一个空文件。我犯了新手错误吗?它创建了testfile.txt,但执行后文件为空。
代码:
#include<stdio.h>
#include<stdlib.h>
int main(int argc, char **argv)
{
FILE *test;
if (test=fopen("testfile.txt","w")==NULL)
{
printf("Open Failed\n");
abort();
}
int i=9;
fprintf(test,"This is a test %d\n",i);
fclose(test);
return 0;
}
【问题讨论】:
标签: c windows mingw codeblocks