Hi, I am writing a function that needs to return either a R S or P. It works fine if what I am inputing is a R S or P. If something else is enter it acts funny. Any suggestions to help me out?
char getUserChoice ()
{
char result;
int again = 0;
do {
char x;
cout << "Please enter Rock, Paper, or Scissors: ";
cin >> x;
cin.ignore(1000, '\n');
x = toupper(x);
if (x == 'R') {
result = 'R';
} else if( x == 'P') {
result = 'P';
} else if (x == 'S') {
result = 'S';
} else {
again = 1;
cout << "Not a good choice. ";
}
} while (again);
return (result);
Thanks