【发布时间】:2013-08-24 05:49:44
【问题描述】:
所以我有这个(不是完整的代码)
char list[1000][10];
strcpy(list[0],"ab");
printf("%d\n",strcmp(list[0],"ab"));
strcmp 返回 0。有人可以解释为什么会这样吗?
提前致谢。
【问题讨论】:
-
因为两个比较的字符串相等,所以
strcmp返回0。 -
linux.die.net/man/3/strcmp、pubs.opengroup.org/onlinepubs/9699919799/functions/strcmp.html,或者如果您的系统有
man命令,则只是man strcmp。 -
见
strcmp()(我建议深入几个级别并花一些时间在整个网站上)。 -
我看到你也在数学板上。请记住,如果您习惯于在 Matlab 中编写东西,那么它的
strcmp()的行为会有所不同(它返回 1 表示相等,而 C 的strcmp()返回 0)。 -
这是一个有趣的想法 - 阅读手册页?可能会更好地理解并更快地回答
标签: c