c++文件操作

匿名 (未验证) 提交于 2019-12-02 23:48:02
#include <iostream> #include <fstream> #include <sstream> using namespace std;  int main() {     fstream picture_fp, rar_fp,output_fp;     char data;     string data2;     char picture_filename[50], rar_filename[50], output_filename[50];     cout << "Please input the picture name :" << endl;     cin>>picture_filename;     cout << "Please input the rar file name :" << endl;     cin >> rar_filename;     cout << "Please input the output file name :" << endl;     cin >> output_filename;      picture_fp.open(picture_filename, ios::in|ios::binary);     if (!picture_fp.is_open()) {         cout << "打开失败" << endl;     }     rar_fp.open(rar_filename, ios::in | ios::binary);     if (!rar_fp.is_open()) {         cout << "打开失败" << endl;     }     output_fp.open(output_filename, ios::out | ios::binary);     while (!picture_fp.eof())     {         data=picture_fp.get() ;//读一个字符         //picture_fp >> data2;//读一行         output_fp << data;     }     picture_fp.close();     while (!rar_fp.eof())     {         data=rar_fp.get() ;//读一行         output_fp << data;     }         rar_fp.close();     output_fp.close();      system("pause"); }

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!