【发布时间】:2015-10-28 20:01:18
【问题描述】:
#include<stdio.h>
#include<process.h>
void main() {
FILE *fp1, *fp2;
char a;
fp1 = fopen("input.txt", "r");
if (fp1 == NULL) {
puts("cannot open this file");
exit(0);
}
fp2 = fopen("output.txt", "w");
if (fp2 == NULL) {
puts("Not able to open this file");
fclose(fp1);
exit(0);
}
do {
a = fgetc(fp1);
fputc(a, fp2);
} while (a != EOF);
fclose(fp1);
fclose(fp2);
getch();
}
我创建了文件 input.txt 和 output.txt,在我运行程序后,我没有看到该文本被复制。 (我也从 cmd 和直接从记事本创建 .txt 文件,但都没有工作)
【问题讨论】:
-
你引用过这个执行非常相似的操作吗? c4learn.com/c-programs/…
-
将 void main(){} 更改为 int main(void){}
标签: c