jvolel
December 19th, 2001, 20:01
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
December 19th, 2001, 20:19
Hmmm, sounds to me like someone is trying to get help with his homework. ;)
Eagle
December 19th, 2001, 20:28
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.
Eagle
December 19th, 2001, 20:42
Wait, you need to include some others for the toupper commands
#include <stdlib.h>
#include <ctype.h>
Eagle
December 19th, 2001, 20:46
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.
jvolel
December 19th, 2001, 22:22
yeah the ctype thing i forgot that and ans, lol thanks a bunch
vBulletin v3.6.2, Copyright ©2000-2009, Jelsoft Enterprises Ltd.