strcmp
returns 0 if the inputs match, some value>0 if the left is "greater" than the right, some value<0 if the left is "lesser" than the right. So usually you want to simply test for equality with strcmp(...)==0
. But there is also the clever version: !strcmp(...)
. Even if you don't use this style, it's useful to learn to recognize it.
And remember that fgets
does not remove the newline character '\n'
from the string.