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();

 

你可能感兴趣的:(C++)