拷贝文件

来源:互联网 发布:菜鸟阎王网络剧百度云 编辑:程序博客网 时间:2024/05/16 13:48
////  io.cpp//  firstcpp////  Created by 陈许兵 on 16/4/9.//  Copyright © 2016年 陈许兵. All rights reserved.//#include <iostream>#include <fstream>using namespace std;bool copy(const char * src, const char * dest){    cout<< src << "," << dest << endl;    ifstream in;    ofstream out;    in.open(src,ios::binary);    if(in.fail()){        cout << "open " << src << " failed!!" << endl;        in.close();        out.close();        return false;    }        out.open(dest,ios::binary);        if(out.fail()){        cout << "open " << dest << " failed!!" << endl;        out.close();        in.close();        return false;    }        out << in.rdbuf();    out.close();    in.close();        return true;}int main(){    cout<<"hello"<<endl;    copy("/Users/chenxubing/books/C和指针.pdf","/Users/chenxubing/books/C和指针.copy.pdf");    return 0;}

0 0
原创粉丝点击