g++ error: ‘stricmp’ was not declared in this scope (but OK for 'strcmp')

前端 未结 5 1647
[愿得一人]
[愿得一人] 2020-12-09 02:26

I am trying to compile the following very very simple piece of source code:

#include 
// #include 
// using namespace std;

cl         


        
5条回答
  •  遥遥无期
    2020-12-09 02:57

    Pretty easy to make your own if need be...

    int my_stricmp (const char *s1, const char *s2)
    {
        while (*s1 != 0 && *s2 != 0)
        {
            if (*s1 != *s2 && ::toupper (*s1) != ::toupper(*s2))
            {
                return -1;
            }
            s1++;
            s2++;
        }
        return (*s1 == 0 && *s2 == 0) ? 0 : -1;
    }
    

提交回复
热议问题