char text[10];
fgets(cmd, 10, stdin);
if (strncmp(cmd, "some text one",13 || "some text two",8) == 0)
{
puts("some text");
}
if (strncmp(cmd, "some text three",13 || "some text four",13) == 0)
{
puts("some text again");
}
我想在这里使用OR运算符,但是当我运行它并输入“ some text one”-输出是这样的:
some text
some text again
为什么?
您不能将OR运算符放在strncmp()
调用的中间。您必须为每个比较分别调用它。