How do I also read a new line using C++ >> operator?
ifstream input(\"doc.txt\".c_str());
vector contents;
while (input >> word) {
conten
You can use std::getline, and push_back
the "\n"
yourself, as mentioned by jaggedSpire:
std::ifstream input("doc.txt");
std::vector contents;
for (std::string line; std::getline(input, line);) {
std::istringstream str(line);
for (std::string word; str >> word;) {
contents.push_back(word);
}
contents.push_back("\n");
}