Tag: strcmp

为什么strcmp不是SIMD优化的?

我试图在x64电脑上编译这个程序: #include <cstring> int main(int argc, char* argv[]) { return ::std::strcmp(argv[0], "really really really really really really really really really" "really really really really really really really really really" "really really really really really really really really really" "really really really really really really really really really" "really really really really really really really really […]

有没有JavaScript strcmp()?

任何人都可以validation这个对我? JavaScript没有strcmp()的版本,所以你必须写出如下所示: ( str1 < str2 ) ? -1 : ( str1 > str2 ? 1 : 0 );

用fgets读取一行strcmp

我试图比较两个string。 一个存储在一个文件中,另一个从用户(stdin)中获取。 这是一个示例程序: int main() { char targetName[50]; fgets(targetName,50,stdin); char aName[] = "bob"; printf("%d",strcmp(aName,targetName)); return 0; } 在这个程序中,当input是"bob"时, strcmp返回一个-1的值。 为什么是这样? 我认为他们应该是平等的。 我怎样才能得到它,所以他们是?

我如何正确比较string?

我试图让一个程序让用户input一个单词或字符,存储它,然后打印出来,直到用户重新input,退出程序。 我的代码如下所示: #include <stdio.h> int main() { char input[40]; char check[40]; int i=0; printf("Hello!\nPlease enter a word or character:\n"); gets(input); printf("I will now repeat this until you type it back to me.\n"); while (check != input) { printf("%s\n", input); gets(check); } printf("Good bye!"); return 0; } 问题在于,即使用户的input(check)与原始input(input)匹配,我也不断获得inputstring的打印。 我比较两个不正确?