ARTICLE AD BOX
Keeping it simple, here's a program that reads into a std::vector<std::string>, each slot contains a "line" of text:
#include <fstream> #include <string> #include <vector> int main() { std::ifstream text_file("dir/filename.txt"); std::vector<std::string> text_container; std::string text_line; while (std::getline(text_file, text_line) { text_container.push_back(text_line); } return EXIT_SUCCESS; }You may want to reserve some room in the vector to prevent a lot of resizing.
58.2k18 gold badges106 silver badges168 bronze badges
