Hello. I'm pretty stuck on my program and I need help. I'm having trouble mainly with the void function I'm required to put in it. I'll place the code here. Also, it is not done yet. I just need it to compile before I can go to the next step.
It returns Q and in the int main it quits the program. I tried adding more breaks, but the compiler gives me an error when I do saying illegal else without matching if, so I changed the else if to if statements, but then the else says the same error.
Update; Got it to work! I switched the loop that was giving me trouble into a switch statement.
First program is it won't compile cause I don't have user or unit in the void and I don't know how to write the parameters to be in void. Sorry. Also, when it was compiling before it wouldn't run and would exit the program right away or there'd just be a blank spot that I couldn't press any key on.
Edit; It compiles but won't run.. Thank you very much for your help.
In addition to what Moschops and IWishIKnew mentioned, you have a few other problems:
L20: The break is going to exit out of the while loop, but there is no return statement after the while loop. Most compilers will generate a return 0. Not what you want.
L22: What if the user didn't enter R,P or S? You're going to return that.
L30: What's the point of the while loop here? You're never going to exit this loop.
L99: You allow the user input to be upper or lower case in your switch statement, but in winner(), you're only checking for upper case.
Line 86,87: Unneeded. You've declared user and unit at 92 and 94.
Line 49: You need to pass unit and used into your winner function. void winner (char unit, char user)
Line 51,60,69: There's an easier way to check for a tie. if (user == unit)
Linr 19 & 96: You allow the user to enter 'Q' or 'q', but only check 'Q' to exit.