######用C语言读取这个文档里面的信息,然后新建一个文件,把abc.txt里面的数据复制到xyz.txt里面去
下面是我做的一个例子,供参考:
#include <stdio.h>
int main(void){
FILE * afp = fopen("f:\\abc.txt","r");
if(afp==NULL){
printf("abc.txt文件打开失败,可能是文件不存在,或目录错误!\n");
return 0;
}
FILE * xfp = fopen("f:\\xyz.txt","w");
if(xfp==NULL){
printf("xyz.txt文件打开失败,可能是新建文件发生错误!\n");
return 0;
}
char ach = getc(afp);
while(ach!=EOF){
putc(ach,xfp);
ach = getc(afp);
}
fclose(afp);
fclose(xfp);
printf("复制abc.txt到xyz.txt成功!\n");
return 0;
}
```c
{int ch;
FILE *fp1,*fp2;
if((fp1=fopen("地址abc.txt","r"))==NULL)
{
printf("Can't open file abc.txt.\n");
exit(0);
}
if((fp2=fopen("地址xyz.txt","w"))==NULL)
{
printf("Can't open file xyz.txt\n");
exit(0);
}
while((ch=fgetc(fp1))!=EOF)
{ fputc(ch,fp2);
}
fclose(fp1);
fclose(fp2);
}
```
关键语句有了,具体修改参考C语言file命令