2013年第6 章 C++流类库 (WHUT版).pptVIP

  • 6
  • 0
  • 约 75页
  • 2017-09-03 发布于江苏
  • 举报
又例如,实现任意名称文件复制的程序如下: #includeiostream.h #includeprocess.h// 为了使用exit() #includefstream.h void main(int argc,char *argv[]) { char ch; if(argc!=3) { cerr″USAGE:dcopy file1 file2\n″; exit(-1); } ifstream source; ofstream dest; source.open( argv[1],ios∷nocreate ); // 源文件必须已经存在 if(!source){ cerr″can not open source file″ argv[1]″\n″; exit(-1); } dest.open(argv[2]); if(!dest) { cerr″can not open destination file″argv[2]″\n″;exit(-1); } while(source.get(ch)) dest.put(ch); cout″DCOPY completed !\n″; source.close(); dest.close(); }

文档评论(0)

1亿VIP精品文档

相关文档