Ok so this is what I have so far Im having problems making the code end once the user guesses the 3 correct digits. any ideas???
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
void playGame();
char getPlayerMove();
int main()
{
playGame();
return 0;
}
void playGame()
{
int a,b,c,d,e,f,x;
char playerMove;
printf("You have 10 guesses of a 3 digit number, I will tell you if you are correct or not\n");
srand(time(NULL));
a = (rand() %6)+1; //random #
b = (rand() %6)+1;
c = (rand() %6)+1; for(x = 0; x<10; x++)
{
printf("Lets start the game, what is your guess? Enter: (#) (#) (#)\n");
scanf("%d%d%d",&d,&e,&f);
if(d == a)
{
printf("Nice! You've got the first number: %d\n", a);
}
if(d == b)
{
printf("Nice! You've got the second number: %d\n", b);
}
if(d == c)
{
printf("Nice! You've got the thrid number: %d\n", c);
}
if(e == a)
{
printf("Nice! You've got the first number: %d\n", a);
}
if(e == b)
{
printf("Nice! You've got the second number: %d\n", b);
}
if(e == c)
{
printf("Nice! You've got the third number: %d\n", c);
}
if(f == a)
{
printf("Nice! You've got the first number: %d\n", a);
}
if(f == b)
{
printf("Nice! You've got the second number: %d\n", b);
}
if(f == c)
{
printf("Nice! You've got the third number: %d\n", c);
}
if(a b c) /* --------------> don't know how to make this to end the code once the user gets the 3 right digits.*/
{
printf("You solved it! %d%d%d\n", a,b,c);
exit(0);
}
}
}