Why does this particular piece of code return false on the strstr() if I input "test"?
char input[100];
int main()
{
fgets(input, 100, stdin);
printf("%s", input);
if(strstr("test message", input))
{
printf("strstr true");
}
}
I thought strstr searched the first param for instances of the second param? It works when I replace input with some text or just assign it something directly, but it seems to not work with fgets.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…