#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; }