所以当我的程序启动时,它会尝试从文件中读取产品列表。但如果该文件不存在,则会显示错误并继续。我遇到的问题是当它显示错误时,它不会继续执行 do while 循环
ifstream input;
input.open("data.txt");
if (input.fail())
{
cout << "\n Data file not found \n";
}
ListItemType data;
input >> data.productname;
while(( !input.eof()))
{
input >> data.category;
input >> data.productprice;
addproduct(head, data);
input >> data.productname;
}
input.close();