在我的循环结束时,我有:
cout<<"\n\n any key to continue or Ctrl+Z to exit.";
它允许用户继续输入数据,或按 退出CtrlZ。当用户决定继续输入数据时,我想隐藏按下的键。
当用户按下任何键以保持循环时,我不希望出现按下的键。我怎样才能做到这一点?我正在使用 Dev-C++。我的函数代码如下。
void student::read()
{
char response; ofstream OS ("student.dat", ios::app);
do
{
cout<<"Name: ";
cin>>name;
cout<<"Age: ";
cin>>age;
cout<<"GPA: ";
cin>>GPA;
//calling writefile to write into the file student.dat
student::writefile();
cout<<"\n\n any key to continue or Ctrl+Z to exit."<<endl<<endl;
cin>>response;
cin.ignore();
}
while(cin); //Ctrl+Z to exit
}