void copie(FILE *fs,FILE *fd){
char *ch;
ch =(char *) malloc(sizeof(char) * 100);
while(!feof(fs))
{
fscanf(fs,"%s",ch);
fprintf(fd, "%s\n", ch);
}
}
int main()
{
FILE *f = fopen("test10.txt", "r");
FILE *e = fopen("testB", "w");
copie(f,e);
fclose(f);
fclose(e);
}
写文件时只换行,没有空格,请问如何能完整的复制原文件内容???
fscanf()只能读不带有空白字符(空格、tab、回车等)的数据,不能完成你的功能
修改如下:
#include <stdio.h>用fscanf真不能实现吗?题目要求要用。
追答那只能用fscanf("%c", &ch ) ;这种写法了。
#include <stdio.h>用fscanf真不能实现吗?题目要求要用。