Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我正在制作字典,必须从各种类型的各种文件夹中读取各种文件!我找到了在控制台目录中显示文件夹的代码!但是我不明白如何阅读这些文件夹中的 txt 文件!并在控制台上显示文件名!请帮我解决这个问题!
这是读取文本文件的方法
std::string line; std::ifstream file ("myfile.txt"); if (file.is_open()) { while (getline(file,line)) { std::cout << line << std::endl; } file.close(); } else { std::cout << "Unable to open file" << std::endl << std::endl; }