[英]Not getting lines - std::getline
I posted this question a couple of days back and i just have another question, I have it outputting the first line of the data but it inst outputting the rest of the lines kinda stumped. 我几天前就发布了这个问题,我还有一个问题,我要输出数据的第一行,但是却要输出其余的行,这简直很困难。
ifstream myReadFile;
myReadFile.open("Data.txt");
system("cls");
std::cout << "Wip" << std::endl;
ifstream myReadFile;
myReadFile.open("Data.txt");
std::string output;
std::getline(myReadFile, output);
std::cout << output << "\n";
myReadFile.close();
system("pause");
return 0;
sample data 样本数据
Name: jobes lobes
Age: 89
Address: 9 neuern_st mucgregor brosbane australia
You need to use a while loop so you can extract continuously. 您需要使用while循环,以便可以连续提取。 Extraction will finish when the stream fails to extract:
当流无法提取时,提取将完成:
while (std::getline(myReadFile, output))
{
std::cout << output << "\n";
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.