What's new

um who can answer this

jvolel

Destoryer of worlds
maybe easy for some or most of you but not for me :-(
i get 1 error: call to undefined function in funcion main
(this is using c++ am a newbie and am just starting out the whole programing thing) also anyone know how i can make it loop so that the player chooses yes they continue from the beging or if a person chooses no they get a game over message

#include
#include

void main()
{
char ans, choice1, choice2;

cout<<"In order to play this game two players are required";
cout<<"choose from the selection.";
cout<<" P. Paper ";
cout<<" R. Rock ";
cout<<" S. Scissors ";
cout<<"Player #1 enter your selection";
cin>> choice1;
choice1 = toupper(choice1);
cout<<"Player #2 enter your selection";
cin>> choice2;
choice2 = toupper(choice2);
{
if (choice1 == 'P' && choice2 == 'P')
{cout << "no one wins";}

if (choice1 == 'R' && choice2 == 'R')
{cout << "tie";}

if (choice1 == 'P' && choice2 == 'R')
{cout<<"Player #2 wins";}

if (choice1 == 'R' && choice2 == 'P')
{cout << "You dumb ass, Player #1 wins";}

if (choice1== 'S' && choice2 == 'S')
{cout << "no one wins";}

if (choice1 == 'P' && choice2 == 'S')
{cout << "Ohh to bad, Player #2 wins";}

if (choice1 == 'S' && choice2 == 'P')
{cout << "Now how you gonna go pick paper, Player #1 wins";}

if (choice1 == 'R' && choice2 == 'S')
{cout << "sorry Player #1 wins";}

if (choice1 == 'S' && choice2 == 'R')
{cout << "player #2 wins";}

cout<< "Do you wish to continue?";
cin>> "Y/N";}} any help is appreciated
:D if its a function i didnt declare then um how would i declare it i swear i dont know :plain:
 

Eagle

aka Alshain
Moderator
OK, first off, your include lines need to include header files. For example.

#include <iostream.h>

And I think you really only need the iostream.h for the cin and cout statements, so just delete the second #include.
 
Last edited:

Eagle

aka Alshain
Moderator
Finally, you need input your answer to a variable like so...

cout<< "Do you wish to continue? (Y/N)";
cin>>ans;
}

And then all thats left is you need to do something with that answer when its entered. Hope this helps.
 
OP
jvolel

jvolel

Destoryer of worlds
oh lol thats what i forgot lolololol

yeah the ctype thing i forgot that and ans, lol thanks a bunch
 

Top