首页 > 其他分享 >cpp ofstream ifstreram binary 文档读写

cpp ofstream ifstreram binary 文档读写

时间:2022-10-18 17:34:25浏览次数:49  
标签:std binary ofstream string dst ifstreram cpp include

include

include

include

include

include <sys/stat.h>

include

void test_copy_binary(std::string src,std::string dst){

    std::ofstream ostrm(dst,std::ios::binary);
    std::ifstream istrm(src,std::ios::binary);
    if (!istrm.is_open() )
    {
        std::cout<<"failed to open: "<<src<<std::endl;
        return ;
    }
    if (!ostrm.is_open())
    {
        std::cout<<"failed to open: "<<dst<<std::endl;
        return ;
    }
    {
        char buf[1];
        while(1){

            istrm.read(buf,1);
            if(istrm.eof())
            {
                break;
            }
            ostrm.write(buf,1);
            istrm.seekg(1024);
        }
        istrm.close();
        ostrm.close();
    }
}

标签:std,binary,ofstream,string,dst,ifstreram,cpp,include
From: https://www.cnblogs.com/simp/p/16803377.html

相关文章