c++读写二进制文件

适合任何文件

尤其是图片,注意那个binary参数fin和fout都必须有,否则要出问题

    std::ifstream fin;
    fin.open("f:\ss.jpg", std::ios_base::binary);
    std::ofstream fout;
    fout.open("d:\ss.jpg", std::ios_base::binary);
    char byte;
    while (fin.get(byte))
    {
        fout << byte;
    }
    fin.close();
    fout.close();
原文地址:https://www.cnblogs.com/qrlozte/p/3524579.html