相关疑难解决方法(0)

如何将一定数量的字符从文件复制到STL-way的向量?

如果我想将文件的内容复制到矢量,我可以这样做:

std::ifstream file("path_to_file");
std::vector<char> buffer(std::istream_iterator<char>(file), 
                         std::istream_iterator<char>());
Run Code Online (Sandbox Code Playgroud)

我的问题是,如果我只想复制第一个n字符,我该怎么做?

编辑我可以编写自己的版本copy,但有没有办法只使用现有的组件?

c++ stl

6
推荐指数
2
解决办法
1026
查看次数

标签 统计

c++ ×1

stl ×1