gpt4 book ai didi

从一个文件复制到另一个文件

转载 作者:行者123 更新时间:2023-11-30 15:11:55 24 4
gpt4 key购买 nike

嗨,这是一个非常简单的小程序,但它对我不起作用:(当我输入 .txt 文件的两个名称后,什么也没有发生。它甚至不返回 0。

#include <stdio.h>

int main()
{
FILE *f1, *f2;
char datei1[100], datei2[100];
char ch;

gets(datei1);
f1=fopen(datei1, "r");
if(f1==NULL){
printf("Cannot open %s", datei1);
return 1;
}
gets(datei2);
f2=fopen(datei2, "a");
if(f2==NULL){
printf("Cannot open %s", datei2);
return 1;
}

while((ch=getch(f1))!=EOF){
putch(ch,f2);
}

printf("Complete");
fclose(f1);
fclose(f2);
return 0;
}

最佳答案

getch更改为fgetcgetch 是一个从键盘读取数据的 VisualC 函数。

关于从一个文件复制到另一个文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35337627/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com