我在书上照着打了个文件复制程序 但不知道怎么测试 书上说要编译连接但我不会 请高手们指点迷津 谢谢
这是程序源代码
#include
#include
using namespace std;
int main(int argCount,char* argValue[])
{
FILE *srcFile="C:\1.dat",*destFile="C:\2.dat";
int ch=0;
if(argCount!=3){
printf("Usage:%s src-file-name dest-file-name\n",argValue[0]);
}else{
if((srcFile=fopen(argValue[1],"r"))==0){
printf("Can not open destination file \"%s\"!",argValue[1]);
}else{
if((destFile=fopen(argValue[2],"w"))==0){
printf("Can not open source file \"%s\"!",argValue[2]);
fclose(srcFile);
}
while((ch=fgetc(srcFile))!=EOF) fputc(ch,destFile);
printf("Successful to copy a file!\n");
fclose(srcFile);
fclose(destFile);
return 0;
}
}
}
return 1;
}
把代码放到编译器中编译连接,比如vs