I'm now learning C and am using a fairly good book to study from (it makes things pretty easy to understand anyhow...) but I came across something that I can't seem to wrap my head around and would like an explanation of what this particular line of code is 'doing'...
here is the function:
int yes_no(char *question)
{
char answer[3];
printf("%s? (y/n): ", question);
fgets(answer, 3, stdin);
return answer[0] == 'y';
}
So from what I understand of C programming so far, this function is supposed to return an int, it takes a string created somewhere outside this function, adds a "? (y/n): " to the end of it and prints that question to the screen, then allows the user to input yes or no and stores that in an array called "answer".....but this looks like it will return a char... or something.... not an int....and why is there an == 'y' in the return line? For the life of me I can't figure out what the return line of this function is doing. Some help would be muchas gracias.