Hi guys. I cant do this right. Please help me.
whatever I type, I always get the loop to repeat. I want the loop to end when i either get sciss, paper or stone as an answer. Otherwise I wanna repeat the loop.
is something wrong with this function?
int human_choice(int choice)
{
char answer[10];
int x;
while(true){
printf("sciss, stone or paper?");
scanf("%s", answer);
clear_stdin();
if (answer=="stone")
break;
thanks. Now i have another problem
I cant get the statistic right. Do I have to make x,y and z = 0? Even when i do that it still shows the wrong statistic
int statistik(int stat)
{
int x, y, z;
int winner;
if (stat==2)
x++;
else if (stat==3)
y++;
else if(stat==1)
z++;
while(x+y+z==10){
if (x>y)
winner=1;
else if (y>x)
winner=2;
else if (x==y)
winner=3;
break;
}
return winner;
}
This statistic is for scissor, paper stone game.
If I win, then X++, if Computer win then Y++.
If draw then Z++.
If i dont put a value in x,y,z then it will automatically take a random value itself.
But if I make them zero, then I think it will start with zero each time i return to this function. And that is not good.
If that's the case, cbeginner, then you'll need to pass the values of x,y,z into the function:
int statistik(int stat,int x,int y,int z)
This way you can specify the values of x y and z and not have to worry about them resetting every time you run the function. If you make them pass by reference, you can even save the values!