How do I use strcasestr()?

前端 未结 2 1314
终归单人心
终归单人心 2021-02-12 23:04

I #include but when I call strcasestr(src, search); I get the following error message implicit declaration of function ‘strcases

相关标签:
2条回答
  • 2021-02-12 23:33

    As specified in the corresponding manpage, since strcasestr is a nonstandard extension you must #define _GNU_SOURCE before the #include <string.h> before any #include (other files may already include <string.h>, thanks @Cubbi for pointing out this potential problem); this can also easily be accomplished by specifying -D_GNU_SOURCE on the compiler command line.

    0 讨论(0)
  • 2021-02-12 23:48

    You must add:

    #define _GNU_SOURCE
    

    before the string.h include, since the function is non-standard.

    0 讨论(0)
提交回复
热议问题