1STRCASECMP(3) Linux Programmer's Manual STRCASECMP(3)
2
3
4
6 strcasecmp, strncasecmp - compare two strings ignoring case
7
9 #include <strings.h>
10
11 int strcasecmp(const char *s1, const char *s2);
12
13 int strncasecmp(const char *s1, const char *s2, size_t n);
14
16 The strcasecmp() function performs a byte-by-byte comparison of the
17 strings s1 and s2, ignoring the case of the characters. It returns an
18 integer less than, equal to, or greater than zero if s1 is found,
19 respectively, to be less than, to match, or be greater than s2.
20
21 The strncasecmp() function is similar, except that it compares no more
22 than n bytes of s1 and s2.
23
25 The strcasecmp() and strncasecmp() functions return an integer less
26 than, equal to, or greater than zero if s1 is, after ignoring case,
27 found to be less than, to match, or be greater than s2, respectively.
28
30 For an explanation of the terms used in this section, see
31 attributes(7).
32
33 ┌────────────────────────────┬───────────────┬────────────────┐
34 │Interface │ Attribute │ Value │
35 ├────────────────────────────┼───────────────┼────────────────┤
36 │strcasecmp(), strncasecmp() │ Thread safety │ MT-Safe locale │
37 └────────────────────────────┴───────────────┴────────────────┘
39 4.4BSD, POSIX.1-2001, POSIX.1-2008.
40
42 The strcasecmp() and strncasecmp() functions first appeared in 4.4BSD,
43 where they were declared in <string.h>. Thus, for reasons of histori‐
44 cal compatibility, the glibc <string.h> header file also declares these
45 functions, if the _DEFAULT_SOURCE (or, in glibc 2.19 and earlier,
46 _BSD_SOURCE) feature test macro is defined.
47
48 The POSIX.1-2008 standard says of these functions:
49
50 When the LC_CTYPE category of the locale being used is from the
51 POSIX locale, these functions shall behave as if the strings had
52 been converted to lowercase and then a byte comparison per‐
53 formed. Otherwise, the results are unspecified.
54
56 bcmp(3), memcmp(3), strcmp(3), strcoll(3), string(3), strncmp(3),
57 wcscasecmp(3), wcsncasecmp(3)
58
60 This page is part of release 5.07 of the Linux man-pages project. A
61 description of the project, information about reporting bugs, and the
62 latest version of this page, can be found at
63 https://www.kernel.org/doc/man-pages/.
64
65
66
67 2017-09-15 STRCASECMP(3)