我尝试在线搜索此问题的解决方案,但未找到任何内容。
我该如何退出一段时间而不必终止程序?
#include <iostream>
int main() {
unsigned int ch;
while(1){
std::cout << "Insert choice: " << std::endl;
std::cin >> ch;
switch(ch){
case 1: std::cout << "case 1" << std::endl;
break;
case 2: std::cout << "case 2" << std::endl;
break;
default: exit(1); //here
}
}
//unreachable code
std::cout << "After switch. I want to go here!" << std::endl; //here
return 0;
}
谢谢!
尝试一下