循环时我如何摆脱困境
How do I get out of while Loop
我已经创建了LinkedList
,我正在尝试为其中一个修改用户。到目前为止,while循环在课程ID中搜索一个,然后如果发现用户将要求编辑。但是它要求用户两次编辑的问题。
我尝试在if
语句甚至exit(0)
下使用"断路",但它不起作用。当if
语句被执行后,它应该让我保持两次循环。
template <typename T> node<T>* ModifyByCourseId(node<T> *front, string className, string courseId)
{
node<T> *curr = front;
while (curr != NULL)
{
if (curr->classId == courseId) {
cout << curr->classId << " " << curr->classDescrip << "." << curr->credit << ":" << curr->creditHr
<< curr->Prerequiste << ":" << curr->PreReq << endl; // print the current node's value to the screen
cout << "Please Modify course title." << endl;
getline(cin, curr->classDescrip);
cout << "Please enter Credit hour(s)." << endl;
cin >> curr->creditHr;
cin.ignore(std::numeric_limits<std::streamsize>::max(), 'n');
cout << "Please enter class pre-requisite(s) if there are more than one separate them by a space." << endl;
getline(cin, curr->PreReq);
break;
}
curr = curr->next;
}
return NULL;
}
我发现了问题。我在语句
相关文章:
- 如何循环打印顶点结构
- 如何在C++中从两个单独的for循环中添加两个数组
- C++我的数学有什么问题,为什么我的代码不能正确循环
- 正在尝试了解输入验证循环
- transform_reduce & 摆脱 for 循环
- 如何摆脱这个做同时循环?
- 如何在将某个值输入到变量中后摆脱 while 循环
- 我如何摆脱循环并继续循环
- 使用 c++ 更早地使用 cout 摆脱 while 循环
- 如何成功摆脱这种做同时的循环
- 循环时我如何摆脱困境
- C++ 比较 2 个不同列表中的值以使用 2 for 循环摆脱重复的数字。无法正确检测重复项
- 我可以在这里摆脱嵌套的循环吗?
- 对如何摆脱没有哨兵值的无限循环感到困惑
- 如何通过在Qt中按esc来摆脱无限while循环
- 如何重构这个while循环以摆脱"continue"?
- 这是一个具有基于数组的列表函数的数据结构项目,我似乎无法摆脱这个无限循环。
- 我如何摆脱这种做同时循环
- 否则会陷入循环困境
- 无法摆脱 do{}while();循环 (C++)