ライブラリ関数呼び出し--統合インスタンス(ファイルcopy)
3031 ワード
#include
/*****************
*name:file_cp.c
*author:QG
*time:2015-05-12
*description:
********************/
int main(int arge,char **argv)
{
FILE *fp_in;
FILE *fp_out;
char buf[1024];
int count_read = 0;
int count_write = 0;
//1.open source file
fp_in = fopen(argv[1],"r+");
//2.open destination file
fp_out = fopen(argv[2],"w+");
//read and write
while((count_read = fread(buf,1,1023,fp_in)) > 0)
{
printf("read %d types !
",count_read);
buf[1023] = '\0';
count_write = fwrite(buf,1,count_read,fp_out);
printf("write %d types!
",count_write);
}
close(fp_in);
close(fp_out);
return 0;
}