How to copy a certain number of chars from a file to a vector the STL-way?

前端 未结 5 818
不知归路
不知归路 2020-12-11 05:27

If I want to copy the contents of a file to a vector, I can do it like that:

std::ifstream file(\"path_to_file\");
std::vector buffer(std::istrea         


        
5条回答
  •  佛祖请我去吃肉
    2020-12-11 05:49

    char *buffer = new char[n];
    file.read(buffer,n);
    std::vector myVector
    for (int i=0;i

    It may not be the prettiest or quickest way, but it is how I would do it.

提交回复
热议问题