C++ 23 · Input, exceptions and threads

Read a file line by line

Read a text file with ifstream and getline.

std::ifstream file("data.txt");
std::string line;
while (std::getline(file, line)) {
    std::cout << line << '\n';
}

Official C++ 23 documentation

More input, exceptions and threads commands

All input, exceptions and threads commands · C++ 23 cheatsheet

Was this page helpful?