#include <fstream> #include<iostream> #include <stdio.h> using namespace std; int main() { char buf[1024]; FILE* rfile; FILE* wfile; rfile = fopen("1.jpg","rb"); // 复制图像,也可以复制任意文件 wfile = fopen("2.jpg", "wb"); cout << "开始复制" << endl; while (!feof(rfile)) { memset(buf, 0, sizeof(buf)); size_t readlen = fread(buf, sizeof(char), sizeof(buf), rfile); size_t writelen = fwrite(buf, sizeof(char), readlen, wfile); } fclose(rfile); fclose(wfile); cout << "done" << endl; }
将图像等文件转为二进制数据再输出实现复制
最新推荐文章于 2024-06-08 20:51:42 发布