#include<stdio.h> #include<stdlib.h> #define BUFSIZE 100 int main(int argc,char *argv[]) { if(argc!=3) { printf("please input in accordance with this format:" " programeName sourceName DestName!\n"); return 0; } FILE *pS,*pD; char *sfName,*dfName; char cbuffer[BUFSIZE]={0}; sfName=argv[1]; dfName=argv[2]; if((pS=fopen(sfName,"rb"))==NULL) { printf("open soucefile %s unsuccessful!\n" "maybe the soucefile is invalid!",sfName); exit(1); } if((pD=fopen(dfName,"wb"))==NULL) { printf("open destfile %s unsuccessful!\n",dfName); exit(1); } while(!feof(pS)) { fread(cbuffer,sizeof(cbuffer),1,pS); if(ferror(pD)) { clearerr(pD); printf("the write operation is unsuccessful\n"); exit(1); } fwrite(cbuffer,sizeof(cbuffer),1,pD); if(ferror(pD)) { clearerr(pD); printf("the write operation is unsuccessful\n"); exit(1); } } fclose(pS); fclose(pD); return 0; }
feof()
feof(pS);
eof
fread
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)