I'm making a simple game in c, and am having troubles passing and receiving information from my function t.
I want the code to essentially run the t function, then print the resulting score. Then, unless one of the scores is greater than three and two greater than the other score, I want it to run t again and print the result.
right now it is running the t function once then getting stuck.
Any help or ideas would greatly appreciated, or if I left out information leave a comment.
#include <stdio.h>
#include <stdlib.h>
void t(int *score1,int *score2)
{
int r,p;
r=rand() % 140;
if(r>30)
{
*score1=score1+1;
}
if(30>r)
{
*score2=score2+1;
}
if(r==30)
{
*score2=score2+1;
}
}
void main(int argc, char *argv[])
{
srand(time(NULL));
int score1 =0;
int score2 =0;
int x =0;
while(x==0)
{
t(&score1, &score2);
printf("%d\n",score1);
printf("%d\n",score2);
if(score1 > 3 && score1==score2+2)
{
printf("Player 1 Wins\n");
x++;
}
if(score2 > 3 && (score2==score1+2))
{
printf("Player 2 Wins\n");
x++;
}
}
return;
}