一个文件(源)复制到另文件(目标)中,原型int*fleCopy(char*dest,
将一个文件(源)中的内容复制到另文件(目标)中。函数原型
int *fleCopy(char *dest, char *sre),其中dest为目标文件名,sSTC为源文件名,贝出错则返回0,否则返回1。并设计main函数,来调用它,比如将“a.txt" '件内容拷贝到“b.txt”。
程序函数参考
int *fleCopy(char *dest, char *sre) {
FILE *fin,*fout;
char c;
fout=fopen(dest,"w");
fin=fopen(sre ,"r");
if(fin==NULL || fout==NULL)
return 0;
while((c=fgetc(fin))!=EOF)
fputc(c,fout);
fclose(fin);
fclose(fout);
return 1;
}
另外,返回为什么要指针?
热门标签: