fgets(input,sizeof(input),stdin);
if (strcmp(input, "quit") == 0){
exit(-1);
}
If I type quit, it does not exit the program; I'm wondering why this is the case.
By the way input
is declared as char *input;
.
The function fgets
might add a newline at the end of the string read. You'll have to check that:
size_t ln = strlen(input) - 1;
if (input[ln] == '\n')
input[ln] = '\0';
or even
strtok(input, "\n");