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';
}
More input, exceptions and threads commands
- Read a line from the keyboard
- Handle exceptions
- Run code on another thread
- Compute a value in the background
- Share a counter between threads
- Time a section of code
All input, exceptions and threads commands · C++ 23 cheatsheet