c++以二进制读取数据到缓存

Posted on 2018-03-29 22:08  yacbo  阅读(478)  评论(0编辑  收藏  举报
char* readFileBytes(const char *name, size_t *len)
{
    ifstream fl(name);
    fl.seekg(0, ios::end);
    *len = fl.tellg();
    char *ret = new char[*len];
    fl.seekg(0, ios::beg);
    fl.read(ret, *len);
    fl.close();
    return ret;
}

 

Copyright © 2024 yacbo
Powered by .NET 9.0 on Kubernetes