<分区>
所以我有这个(不是完整的代码)
字符列表[1000][10];
strcpy(列表[0],"ab");
printf("%d\n",strcmp(list[0],"ab"));
并且 strcmp 返回 0。有人可以解释为什么会这样吗?
提前致谢。
标签 c
<分区>
所以我有这个(不是完整的代码)
字符列表[1000][10];
strcpy(列表[0],"ab");
printf("%d\n",strcmp(list[0],"ab"));
并且 strcmp 返回 0。有人可以解释为什么会这样吗?
提前致谢。
最佳答案
strcmp
如果 list[0]
在这种情况下包含“ab”,方法将返回 0。
它返回:
Returns an integral value indicating the relationship between the strings:
A zero value indicates that both strings are equal.
A value greater than zero indicates that the first character that does not match has a greater value in str1 than in str2; And a value less than zero indicates the opposite.
关于c - strcmp 没有正确比较字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18412345/