Why does this particular piece of code return false in strstr () if I entered "test"?
char input[100];
int main()
{
fgets(input, 100, stdin);
printf("%s", input);
if(strstr("test message", input))
{
printf("strstr true");
}
}
I thought strstr was looking for the first parameter for instances of the second parameter? It works when I replace the input with some text or just assign it something directly, but it doesn't seem to work with fgets.
source
share