u010904597 2014-01-21 08:56 采纳率: 0%
浏览 1846

C++ 文件操作程序怎么测试

我在书上照着打了个文件复制程序 但不知道怎么测试 书上说要编译连接但我不会 请高手们指点迷津 谢谢
这是程序源代码
#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;
}

  • 写回答

1条回答

  • oyljerry 2015-01-02 12:35
    关注

    把代码放到编译器中编译连接,比如vs

    评论

报告相同问题?

悬赏问题

  • ¥50 永磁型步进电机PID算法
  • ¥15 sqlite 附加(attach database)加密数据库时,返回26是什么原因呢?
  • ¥88 找成都本地经验丰富懂小程序开发的技术大咖
  • ¥15 如何处理复杂数据表格的除法运算
  • ¥15 如何用stc8h1k08的片子做485数据透传的功能?(关键词-串口)
  • ¥15 有兄弟姐妹会用word插图功能制作类似citespace的图片吗?
  • ¥200 uniapp长期运行卡死问题解决
  • ¥15 latex怎么处理论文引理引用参考文献
  • ¥15 请教:如何用postman调用本地虚拟机区块链接上的合约?
  • ¥15 为什么使用javacv转封装rtsp为rtmp时出现如下问题:[h264 @ 000000004faf7500]no frame?