读取多个二进制文件合并到一个指针指向

博客主要围绕读取二进制文件并将其合并到一个指针的操作展开,但具体内容缺失。推测涉及文件读取、二进制处理及指针操作等信息技术相关内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

    const int img_size = 1843200;
    const int all_size = img_size*4;
    ap_uint<PIXEL_BLOCK> * pixel_in;    
    pixel_in = (ap_uint<PIXEL_BLOCK>*)malloc(all_size);
    // memset(pixel_in, 0,  all_size );//
    std::ifstream fp[4];
    fp[0].open("../../data/out/out_front.bin", std::ios::in | std::ios::binary);
    fp[1].open("../../data/out/out_right.bin", std::ios::in | std::ios::binary);
    fp[2].open("../../data/out/out_rear.bin", std::ios::in | std::ios::binary);
    fp[3].open("../../data/out/out_left.bin", std::ios::in | std::ios::binary);
    for(int i=0;i<4;i++){
        if (fp[i].is_open()) {
            //fp.seekg(i * size);
            char* buffer = new char[img_size];
            fp[i].read(buffer, img_size);
            // memcpy(&pixel_in[0], buffer, img_size);
            memcpy(&pixel_in[i*img_size/4], buffer, img_size);
        }
        else{
            std::cout << "cannt open out" << std::endl;
        }
    }
    std::cout << std::hex << pixel_in[0] << std::endl;
    std::cout << std::hex << pixel_in[1] << std::endl;
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值