//将source.txt文本文件中的内容复制到dest.txt文本文件中,再将dest.txt文件中的内容读出显示到屏幕。
#include<stdio.h>
#include<stdlib.h>
int main()
{
FILE *ph,*pf;
char ch[100],source[100],dest[100];
gets(source);
gets(dest);
if((ph=fopen(source,"r"))==NULL)
{
printf("Cannot open");
exit(1);
}
if((pf=fopen(dest,"w"))==NULL)
{
printf("Cannot creat");
exit(1);
}
while(fgets(ch,100,ph)!=NULL)
fputs(ch,pf);
fclose(ph);
fclose(pf);
return 0;
}
//将source.txt文本文件中的内容复制到dest.txt文本文件中,再将dest.txt文件中的内容读出显示到屏幕。
#include<stdio.h>
#include<stdlib.h>
int main() {
FILE *ph, *pf;
char ch[100], source[100], dest[100];
if((ph = fopen("source.txt", "r")) == NULL) {
printf("Cannot open");
exit(1);
}
if((pf = fopen("dest.txt", "w")) == NULL) {
printf("Cannot creat");
exit(1);
}
while(fgets(ch, 100, ph) != NULL){
fputs(ch, pf);
printf("%s",ch);
}
fclose(ph);
fclose(pf);
return 0;
}
显示代码在哪里?
source.txt这个字符串在哪,你只定义了一个叫source的数组,但是没有给它赋值,它是空字符串啊
而且你除了print一个错误,也并没有输出任何数据的代码
一句话,你这代码乱七八糟,能实现你想要的功能才见鬼了