gpt4 book ai didi

c - strcmpi 代码不会编译但 strcmp 会?

转载 作者:太空宇宙 更新时间:2023-11-03 23:49:07 29 4
gpt4 key购买 nike

<分区>

我有一个问题,为什么我的代码在使用 strcmpi 时无法编译。我用 strcmp 测试了相同的代码并且有效。不确定为什么这不起作用。

这是我得到的编译错误:

gcc -std=c99 strcmpi_test.c -o strcmpi_test
strcmpi_test.c: In function 'main':
strcmpi_test.c:15: warning: implicit declaration of function 'strcmpi'
strcmpi_test.c:30:2: warning: no newline at end of file
/tmp/cceKXLcn.o: In function `main':
strcmpi_test.c:(.text+0x50): undefined reference to `strcmpi'
collect2: ld returned 1 exit status



#include <stdio.h>
#include <string.h>


int main()
{

char name[10];

char name2[10] = "bob";

printf("what is your name : ");
fgets(name,10,stdin);

if(strcmpi(name,name2) == 1)
{

printf("name == %s name2 == %s your names are the same\n",name,name2);

} else {

printf("name == %s name2 == %s your names are NOT the same\n",name,name2);


}


return 0;

}

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com