I met a problem here which is i used fgets to read user inputs, my goal is compare the inputs with "quit" by using strcmp function. if it returns 0 i will print it can compare otherwise it can not, but the current problem is it prints things out even the input string wasn't quit.
Below is my code and the outputs i have got..
#include <stdio.h>
#include <unistd.h>
int main()
{
char buffer[355];
printf("start say something here...\n");
fgets(buffer, 355, stdin);
printf("u entered %s", buffer);
if (!strcmp(buffer, "quit"));
{
printf("i can compare\n");
}
}
Outputs 1
start say something here...
no
u entered no
i can compare
Outputs 2
start say something here...
quit
u entered quit
i can compare