STDIN Redirection: How to finish the program once fgets () reads a scheduled end line


Ok, so I have a program that reads lines of a file. However once it reaches the line
*** END ***
it's meant to see that
char str[100];
while(fgets(str,100,stdin) != NULL && strcmp(str,"*** END ***"))
and the while loop should stop because strcmp will be equal to 0 therefore making the while loop false.

However it doesn't. I think this is because str has a different amount of chars (I'm assuming the rest after the copied line have nothing inside of them?) than "*** END ***". How can I fix my program so that it will end once the line is read? Thanks.

OK, so I know now it's because in my example text, I had a line after that one. Once deleted it works fine. But how can I make it end whether there's a line after it or not?

you can use

char * strstr ( const char *, const char * )

A pointer to the first occurrence in str1 of the entire sequence of characters specified in str2, or a null pointer if the sequence is not present in str1.