【发布时间】:2021-02-20 15:33:16
【问题描述】:
当我通过互联网上的源代码搜索新信息时,
我看到有人将goto 用于一个变量,而这个变量与cout 相关联
声明,同std::cout。
他写了a:cout。
你能帮我找到这个函数的名字吗?
void Main_Menu() {
int i;
cout << "\n\n\n\n\n\n\n\n\n\n\n\n\t\t\t\t\t\t\t\t HOSPITAL MANAGEMENT SYSTEM \n\n";
cout << "\n\n\t\t\t\t\t\tPlease, Choose from the following Options: \n\n";
cout << "\t\t\t\t\t\t _________________________________________________________________ \n";
cout << "\t\t\t\t\t\t| |\n";
cout << "\t\t\t\t\t\t| 1 >> Add New Patient Record |\n";
cout << "\t\t\t\t\t\t| 2 >> Add Diagnosis Information |\n";
cout << "\t\t\t\t\t\t| 3 >> Full History of the Patient |\n";
cout << "\t\t\t\t\t\t| 4 >> Information About the Hospital |\n";
cout << "\t\t\t\t\t\t| 5 >> Exit the Program |\n";
cout << "\t\t\t\t\t\t|_________________________________________________________________|\n\n";
a: cout << "\t\t\t\t\t\tEnter your choice: ";
cin >> i;
if (i > 5 || i < 1) {
cout << "\n\n\t\t\t\t\t\tInvalid Choice\n";
cout << "\t\t\t\t\t\tTry again...........\n\n";
goto a;
} //if inputed choice is other than given choice
【问题讨论】:
-
您是在询问
goto和标签,因为这就是这段代码正在做的事情。 -
顺便说一句,使用空格而不是制表符。一个制表符可以代表 8、3、4 或 2 个空格。一个制表符可能意味着间隔到下一个制表位(可能是间歇性的)。也可以忽略标签。