123456789101112131415161718192021222324
#include <iostream> #include <fstream> #include <vector> #include <string> #include <utility> int main() { std::vector<std::string> lines; { std::ifstream in ("file.txt"); std::string line; while(std::getline(in, line)) { lines.push_back(std::move(line)); } } for(std::string &line : lines) { std::cout << line << std::endl; } }