-2

I am trying to compare two strings to see if they are the same regardless of case. I've found a few functions. strcmp() is case sensitive but some others like stricmp() isn't in C and strcasecmp() dosen't seem to work either. Can anyone suggest a function in C which does this?

user1636588
  • 101
  • 2
  • 6

1 Answers1

0
int iequals(const char* a, const char* b){
    unsigned int size1 = strlen(a);
    if (strlen(b) != size1)
        return 0;
    for (unsigned int i = 0; i < size1; i++)
        if (tolower(a[i]) != tolower(b[i]))
            return 0;
    return 1;
}
anatolyg
  • 26,506
  • 9
  • 60
  • 134
Shravan40
  • 8,922
  • 6
  • 28
  • 48