怎么写输入错误信息?按我写的话,”输入错误信息“会循环很多遍,没有思路
bool opFlag = true;
while (opFlag)
{
system("cls");
cout << "**********************************************" << endl;
cout << "* 查询学生成绩 *" << endl;
cout << "**********************************************" << endl;
cout << "* 1:按学号查询 *" << endl;
cout << "* 2:按姓名查询 *" << endl;
cout << "* 3:按性别查询 *" << endl;
cout << "* 4: 按班级查询 *" << endl;
cout << "* 0:返回上一级菜单 *" << endl;
cout << "**********************************************" << endl;
cout << "请输入您的选择:";
cin >> n;
switch(n)
{
case'1':
cout << "请输入学号:";
cin >> m;
for (int k = 0; k < _studentInfo.size(); k++)
{
if (_studentInfo[k]._num == m)
{
cout << "**************************** 成绩列表 ******************************" << endl;
cout << " 学号, 姓名, 性别, 班级名称, 考勤, 作业, 实验, 考试, 总评" << endl;
_studentInfo[k].display();
system("pause");
char c = getchar();
}
}
for (int k = 0; k < _studentInfo.size(); k++)
{
if (_studentInfo[k]._num != m)
{
char c = getchar();
cout << "输入错误学号!" << endl;
}
}
break;