为什么我的 strcasecmp 函数会带来错误消息? (C)

Why is my strcasecmp function bringing error messages? (c)

我正在研究 cs50 pset5 拼写器,现在我正在使用检查功能。我使用 strcasecmp 不区分大小写地比较两个字符串。我在 cs50 Ide(他们在 pset1 中给我们的那个)中编码,我的 strcasecmp 函数带来了这个错误消息:

clang -ggdb3 -O0 -Qunused-arguments -std=c11 -Wall -Werror -Wextra -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wshadow -c -o speller.o speller.c
clang -ggdb3 -O0 -Qunused-arguments -std=c11 -Wall -Werror -Wextra -Wno-sign-compare -Wno-unused-parameter -Wno-unused-variable -Wshadow -c -o dictionary.o dictionary.c
dictionary.c:37:12: error: implicit declaration of function 'strcasecmp' is invalid in C99 [-Werror,-Wimplicit-function-declaration]
       i = strcasecmp(word, cursor -> word);
           ^
1 error generated.
Makefile:2: recipe for target 'speller' failed
make: *** [speller] Error 1

这是我的检查功能代码:

bool check(const char *word)
{ 
    unsigned int lol = hash(word);
     // TODO
   int i;
   node *cursor =table[lol];;
    while(cursor != NULL)
    {
     
       i = strcasecmp(word, cursor -> word);
      if(i == 0)
      {
          return true;
      }
      cursor = cursor->next;
   
    }
    
    
    return false;
}

我包括了这些 headers:

#include <ctype.h>
#include <stdio.h>
#include <sys/resource.h>
#include <sys/time.h>
#include <string.h>
#include <stdlib.h>
#include "dictionary.h"

请帮我找出我的问题。我知道它在 strcasecmp 函数中,但我不知道在哪里。如果有人有任何想法,请告诉我。我已经被困在拼写器上好几个星期了。谢谢。

根据 POSIX 7 strcasecmp() documentation:

SYNOPSIS

#include <strings.h>  <==== NOTE the second "s"

int strcasecmp(const char *s1, const char *s2);

strcasecmp() 的正确 #includestrings.h,而不是 string.h