#include#include int main() { std::string line; std::getline(std::cin, line); std::cout << "You typed: " << line << std::endl; return 0; }
#includeIn the above example, the getline function is used to read a line of text from a file called 'example.txt'. The file is opened using the std::ifstream class and then read line by line until the end of the file is reached. Each line of text is output to the console. The getline function is part of the#include #include int main() { std::ifstream file("example.txt"); if (file.is_open()) { std::string line; while (std::getline(file, line)) { std::cout << line << std::endl; } file.close(); } return 0; }