|
简单写了一个.大家别见笑.有什么好的方法也可以讨论一下.呵呵
对于文件存在与否没有作判断,目的是为了程序简洁.
在VC.NET里编译通过.但使用的是C函数.
/*copy.cpp file */
#include <stdio.h>
#define BUFFER 4096
int main(int argc, _TCHAR* argv[])
FILE *in,*out;
if( (in=fopen(argv[1],"rb"))==NULL ){
printf("in error");
exit(1);
}
if( (out=fopen(argv[2],"wb"))==NULL ){
printf("out error");
if( in!=NULL ){
fclose(in);
}
exit(1);
}
unsigned char buffer[BUFFER];
long size;
do{
size = fread(buffer,1,BUFFER,in);
fwrite(buffer,1,size,out);
}while( size==BUFFER );
printf("copy finish");
fclose(in);
fclose(out);
return 0;
}
[ Last edited by hjack on 2005-12-26 at 14:11 ] |
|