1 #include <iostream> 2 #include <string> 3 #include <fstream> 4 5 int main() { 6 std::ifstream in_file("test.txt"); 7 std::string line; 8 while ( getline(in_file, line) ) { 9 std::cout << line; 10 } 11 }
不需要检查test.txt是否存在
时间: 2024-10-14 08:46:08
1 #include <iostream> 2 #include <string> 3 #include <fstream> 4 5 int main() { 6 std::ifstream in_file("test.txt"); 7 std::string line; 8 while ( getline(in_file, line) ) { 9 std::cout << line; 10 } 11 }
不需要检查test.txt是否存在