Name

strcasecmp, strncasecmp
- compare two strings ignoring case

Library

libc.lib

Synopsis

  #include <strings.h>
  int strcasecmp (const char *s1, const char *s2);
  int strncasecmp (const char *s1, const char *s2, size_t len);

Return values

The strcasecmp and strncasecmp return an integer greater than, equal to, or less than 0, according as s1 is lexicographically greater than, equal to, or less than s2 after translation of each corresponding character to lower-case. The strings themselves are not modified.

Detailed description

The strcasecmp and strncasecmp functions compare the null-terminated strings s1 and s2. The strcasecmp() function compares the two strings s1 and s2 , ignoring the case of the characters.

The strncasecmp compares at most len characters.


Examples

#include <string.h>
#include <stdio.h>
int main()
{
    int ret;
    ret = strcasecmp("ABC","abc");
    printf("strcasecmp of \"ABC\" \"abc\" is %d\n",ret);
    ret = strcasecmp("abc","abc");
    printf("strcasecmp of \"abc\" \"abc\" is %d\n",ret);
    return 0;   
}

         

Output

strcasecmp of "ABC" "abc" is 0
strcasecmp of "abc" "abc" is 0

         

See also

bcmp, memcmp, strcmp, strcoll, strxfrm, tolower

Feedback

For additional information or queries on this page send feedback

© 2005-2007 Nokia

Top