【发布时间】:2016-07-10 17:14:21
【问题描述】:
当用户尝试搜索数据文件中不可用的内容时,如何使用cout 向用户输出消息?我试过以下代码:
cin>>temp;
fstream a;
a.open("Account.dat",ios::app|ios::in|ios::out);
while(a>>acno>>type>>cid>>credit>>debit>>tellid){
if(temp==acno){
cout<<"Customer ID : "<<cid<<endl;
break;
}//if not found , display an error message,I've tried using else block here
}
谢谢!
【问题讨论】:
-
5您添加了C标签是因为它们以相同的字母开头?不要垃圾邮件无关语言的标签!
-
那么为什么
else不起作用? -
FiestStep - 它只返回第一条记录的结果
-
@Olaf 没有 C 标签。
-
@Olaf - c 和 c++ 不相关? :D
标签: c++ c++11 file-handling