When I was searching for new information through source code in the internet,
I saw someone used goto
to a variable, and this variable was linked with a cout
statement, the same as in std::cout
.
He wrote a:cout
.
Can you help me to find the name of this function?
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
There is no variable a
linked to cout
. The a:
is a label that you can jump to with goto a;
. The code could also be written like
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
Funny side note: why is
void f()
{
http://stackoverflow.com
https://stackoverflow.com
}
valid C? Because http
and https
are seen as labels and //
starts a comment.