首页 > 其他 > 详细

文件复制

时间:2018-05-12 13:40:53      阅读:194      评论:0      收藏:0      [点我收藏+]
#include"iostream"
#include"iomanip"
#include"fstream"
using namespace std;
//复制 文件path2 到 文件path1,path1不存在就创建
bool fileCopy(char *path1,char *path2);
int main(){
    fileCopy("my1.png","屏幕截图(1).png");
    return 0;
}

bool fileCopy(char *path1,char *path2){
    fstream inf,onf;
    char *file1 = new char[1024];
    inf.open(path2,ios::in|ios::binary);
    onf.open(path1,ios::out|ios::binary);
    if(!inf||!onf){
        cout<<"open false!"<<endl;
        return false;
    }
    while(!inf.eof()){
        inf.read(file1,1024);
        onf.write(file1,1024);
    }
    inf.close();
    onf.close();
    return true;
}

 

文件复制

原文:https://www.cnblogs.com/oleolema/p/9028416.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!