拷贝文件

//
//  io.cpp
//  firstcpp
//
//  Created by 陈许兵 on 16/4/9.
//  Copyright © 2016年 陈许兵. All rights reserved.
//

#include 
#include 

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"<

你可能感兴趣的:(一步一步CPP)