Ok I've gotten everything up and running other that the functions that check and report to the user if any guesses are correct and whether they are in the correct positions. That's what my variables wp and rp are going to be for. Any tips on how to get something like that running?
Code:
#include <stdio.h>
#include <stdlib.h>
#include <time.h>
int main()
{
srand(time (NULL));
int pick[4];
int guess[4];
int loop;
int rp=0;
int wp=0;
int flag[4];
for(int i=0; i<4; i++) // selects a random set of 4 integers
{
pick[i] = rand() %9;
}
printf("\t***Hello Mr. or Mrs.(or Ms. I guess) Number Guesser!***\n");
printf("Guess four positive integers, you have ten tries to complete the code.\n");
printf("Enter negative one (-1) as your first entry if you want to see the code, you naughty cheater you.\n");
printf("If you guess correctly, there will be cake!\n");
for(loop=0;loop<10;loop++)
{
printf("\nWhat is your guess?\n\n");
printf("You have %d correct numbers in the correct place\n\n", rp);
printf("You have %d correct numbers in the wrong place\n\n", wp);
scanf("%d %d %d %d", &guess[0], &guess[1], &guess[2], &guess[3]);
if(guess[0]<0)
{
printf("\nThe answer is\t:\t%d%d%d%d\n", pick[0], pick[1], pick[2], pick[3]);
}
else if(pick[0] == guess[0] && pick[1] == guess[1] && pick[2] == guess[2] && pick[3] == guess[3])
{
printf("You win! However, about that whole cake thing, it was a lie. Sorry.");
break;
}
else if(pick[0] != guess[0] && pick[1] != guess[1] && pick[2] != guess[2] && pick[3] != guess[3] && loop==9)
{
printf("\nThe code was : %d %d %d %d\nYou lose, dummy!\n\n",pick[0], pick[1], pick[2], pick[3]);
}
}
return 0;
}