Hello.
What i'm required to do is to create a menu, call a function, and ask the user if he wants to continue.
In this case the user will play a slot machine.
case 4:
cout << "Type SPIN to start" << endl;
cin >> spin;
again = 0;
do
{
slotmachine(spin);
cout << "would you like to play again? Press 1 to exit" << endl;
cin >> again;
}
while (again != 0);
system("pause");
break;
the thing is that no matter what I input after the question to play again, the function keeps running.
Also, sometimes it says winner even though numbers aren't matching.
Yes, you will just need to wrap the case in braces
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
case 4:
{ // <---
cout << "Type SPIN to start" << endl;
cin >> spin;
again = 0;
do
{
slotmachine(spin);
cout << "would you like to play again? Press 1 to exit" << endl;
cin >> again;
}
while (again != 0);
system("pause");
break;
} // <---
by looking at the unneeded parameter in `slotmachine()' I deduce that `spin' is a char
A char can only hold one character, if you are inputting "SPIN" then you are passing "PIN" when doing cin >> again;