Hi I just got into coding while on my sem break and now practicing by written a simple odd or even bet so I made a small UI as bellow
int Option()
{
int UI;
bool Conformation = 0;
while (Conformation == 0)
{
cout << "For odd enter 1 , for even enter 2\n Insert : ";
cin >> UI;
Conformation = 0;
switch (UI)
{
case 1:
cout << "You have selected odd \n are you sure?\n 1.Yes 2.NO \n Insert :";
cin >> Conformation;
break;
case 2:
cout << "You have selected even \n are you sure? 1.Yes 2.NO \n Insert :";
cin >> Conformation;
break;
default:
cout << "Invalid entery please enter another value\n";
Conformation = 0;
break;
}
}
return UI;
}
I expected it to loop through line 8 "cin >> UI;" when Conformation = 0 , but it just skip any form of "cin"
thank in advance.
You have:
cout << "You have selected odd \n are you sure?\n 1.Yes 2.NO \n Insert :";
cin >> Conformation;
Use of 1
or 2
for Confirmation
is most likely tripping you up since Confirmation
is of type bool
.
I suggest changing the type of Confirmation
to int
.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.