Hi, I am trying to compile some code using a g++ GNU Compiler, and it keeps complaining. Other people have told me the exact same code compiles with their compiler. Anyone know why?
Here is the code...
#include <iostream>
#include <ctime>
#include <cstdlib>
using namespace std;
char getUserChoice();
char getCompChoice();
int main()
{
char userChoice;
char compChoice;
compChoice = getCompChoice();
userChoice = getUserChoice();
cout << "User picked: " << userChoice << endl;
cout << "Computer picked: " << compChoice << endl;
return (0);
}
char getUserChoice ()
{
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') {
return ('R');
} else if (x == 'P') {
return ('P');
} else if (x == 'S') {
return ('S');
} else {
again = 1;
cout << "Not a good choice. ";
}
} while (again == 1);
}
char getCompChoice()
{
srandom(time(0));
int n = random() % 3;
n++;
if (n == 1) {
return ('R');
} else if (n == 2) {
return ('P');
} else {
return ('S');
}
}
This is compiler error.
cc1plus: warnings being treated as errors
hw3b.cc: In function 'char getUserChoice()':
hw3b.cc: warning: control reaches end of non-void function