Ok, now I'm feeling dumb and all, but I need help on how to a print a secret random code if I said yes on cheat, and I should not let it be printed if the answer on the cheat is no(but it should still be stored in a value for later use). so I'm just curious should I make the function on cheat "int cheat" instead of "void cheat"? cause I don't know how to give the value of cheat to main so that it can answer the question to print the secret random code. And I need help finding out in what variable the secret code is stored in so I can print it on int main() P.S. I need it as functions.
void random()
{
int i, j;
char* animals[size] = {"ant", "bear", "cat", "dog", "emu", "goat", "lizard", "monkey", "parrot", "rabbit", "snake", "tiger"};
char* chosen[4] = {"", "", "", ""};
srand(time(NULL));
for( i = 0; i < 4; i++ )
{
chosen[i] = animals[rand()%12];
for( j = 0; j < 4; j++ )
if( strcmp(chosen[i], chosen[j]) == 0 && j != i )
{
i--;
break;
}
}
for( i = 0; i < 4; i++ )
{
printf("%c", chosen[i][0]);
}
printf("\n");
}
void cheat()
{
char cheat;
printf("need cheats? <y-Yes,n-No>");
scanf(" %c",&cheat);
while(cheat != 'y' && cheat != 'n')
{
scanf("%c",&cheat);
}
}
int main()
{
cheat(cheat);
random();
system("pause");
}
this is my code so far. Hope you can help I will appreciate any kind of help given.