📜  c++ 将文件加载为向量 - C++ 代码示例

📅  最后修改于: 2022-03-11 14:44:56.434000             🧑  作者: Mango

代码示例1
#include 
#include 
#include 
#include 
#include  // for std::copy

int main()
{
  std::ifstream is("numbers.txt");
  std::istream_iterator start(is), end;
  std::vector numbers(start, end);
  std::cout << "Read " << numbers.size() << " numbers" << std::endl;

  // print the numbers to stdout
  std::cout << "numbers read in:\n";
  std::copy(numbers.begin(), numbers.end(), 
            std::ostream_iterator(std::cout, " "));
  std::cout << std::endl;

}