C++: Read a file line by line
A short, tested C++ example for read a file line by line. Copy it and adjust the names and paths for your project.
C++
#include <fstream>
#include <string>
std::ifstream in("data.txt");
std::string line;
while (std::getline(in, line)) {
std::cout << line << "\n";
}Find it in Zest
Search for “cpp read a file line by line” in Zest and this example appears above the results, with other matches to choose from. Searches stay private.