I'm trying to write a mastermind program but I'm stuck with string inputs. I try get user guess and when I try to print it it gives error I don't know why here is that part of the program
char* UserGuess[4];
void *Guess()
{
long i;
printf("Enter your guess: ");
for(i=0;i<4;i++)
{
fgets(UserGuess, 4, stdin);
}
return UserGuess;
}
int main()
{
int userchoice=0, i;
while(userchoice!=2)
{
Guess();
printf("%s\n", UserGuess[0]);
break;
}
}
userchoicedoesn't change at all in your loop. And the call toGuess()is useless since you ignore the return value.UserGuessis an array of pointers but you seem to be using it like an array. There are too many basic issues in your code. Better read a proper text book.