I'm working on program where I would like to find a match in a string. I am using the strstr()
function to get the job done, but it has a weird behaviour.
I am using fgets()
to read the string and then using strstr()
to find a match, but it always returns null if the string is not the exact same as the match.
For example:
>string to search match in : This is testing environment
>match : test
>returns : (null)
>string to search match in : test
>match : test
>returns : test
Why does it behave this way and can I fix this behaviour?