私のループの終わりに私は持っています:
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
}