RenderedAwake
Technical User
Ok, I'm writing a paper, rock, scissors program & I've run into a bit of a problem. I think I have everything set up for the most part but I'm stuck when it comes to these strcmpr string thing. I want the program to have the computer randomly play against the player, so I set it up so that according to the random numbers, the computer choice becomes equal to a word ( a string array). However, for the player choice I set it up as a char array, and when I compare the computer choice to the player choice it doesn't work. I'm guessing this is because one is a char array and the other is a string array, but I don't know how to do this properly. I tried changing the player choice into a string but it didn't even recognize the word string. Any help and suggestions would be greatly appreciated!
(this is my code thus far)
(this is my code thus far)
Code:
srand((unsigned)time(NULL));
int d=rand()%3;
if (d==0)
{
cout<<"Computer choice: Paper"<<endl;
computerChoice="Paper";
}
else if (d==1)
{
cout<<"Computer choice: Rock"<<endl;
computerChoice="Rock";
}
else if (d==2)
{
cout<<"Computer choice: Scissors"<<endl;
computerChoice="Scissors";
}
cout<<d;
return 0;