c语言把一个文件中的内容复制到另外一个文件中的代码的另外一种写法
#include<stdio.h> /*標準輸入輸出*/ ??
#include<string.h> /*字符串操作*/ ??
#include<stdlib.h> /*其它函數*/?
int copy(char *infile,char *outfile) ?
{ ?
? ? FILE *input,*output; ?
? ? char temp; ?
? ? if(strcmp(infile,outfile)!=0 && ((input=fopen(infile,"rb"))!=NULL) && ((output=fopen(outfile,"wb"))!=NULL)) ?
? ? { ?
? ? ? while(!feof(input)) ?
? ? ? { ?
? ? ? ? fread(&temp,1,1,input); ?
? ? ? ? fwrite(&temp,1,1,output); ?
? ? ? } ?
? ? ? fclose(input); ?
? ? ? fclose(output); ?
? ? ? return 0; ?
? ? } ?
? ? else return 1; ?
} ?
int main()
{
? char *infile ="1.txt";
? char *outfile="2.txt";
? copy(infile,outfile);
}
總結
以上是生活随笔為你收集整理的c语言把一个文件中的内容复制到另外一个文件中的代码的另外一种写法的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: NIST指纹数据识别(二)数据处理
- 下一篇: 腾讯企业邮箱java-收发邮件