1、复制一个文件,产生备份,使用了缓冲区 code: #include<stdlib.h> #include<stdio.h> #include<string.h> int main(int argc,char * argv[]) { FILE* fp_src,*fp_des; int i; char buffer[10]; if((fp_src=fopen(argv[1],"r+"))==NULL){ perror("open1"); exit(EXIT_FAILURE); } if((fp_des=fopen(argv[2],"w+"))==NULL){ perror("open2"); exit(EXIT_FAILURE); } do{ memset(buffer,'/0',10); i=fread(buffer,1,10,fp_src); fwrite(buffer,1,i,fp_des); }while(i==10); fclose(fp_src); fclose(fp_des); return 0; }