strstr not functioning

It’s because fgets stores the newline character so when strstr does a comparison it fails.

From the man page:

fgets() reads in at most one less than size characters from stream
and stores them into the buffer pointed to by s. Reading stops after
an EOF or a newline. If a newline is read, it is stored
into the buffer. A ‘\0’ is stored after the last character in the buffer.

Leave a Comment