strcasecmp(3)

strcasecmp3

Strings case-insensitive compare

Usage

#include <strings.h>

int strcasecmp(const char *s1, const char *s2);

Library

Standard C library (libc, -lc)

Overview

The strcasecmp() function performs a byte-by-byte comparison of the strings s1 and s2, ignoring the case of the characters. It returns an integer less than, equal to, or greater than zero if s1 is found, respectively, to be less than, to match, or be greater than s2.

Return value

The strcasecmp() function returns an integer less than, equal to, or greater than zero if s1 is, after ignoring case, found to be less than, to match, or be greater than s2, respectively.

Attributes

For an explanation of the terms used in this section, see attributes(7).

InterfaceAttributeValue
strcasecmp()Thread safetyMT-Safe locale

Releases

19 releases since Debian 1.1 (Buzz); the text changed 13 times.

  1. 1.1–2.2
  2. 3.0
  3. 3.1
  4. 4.0
  5. 5.0
  6. 6.0
  7. 7
  8. 8
  9. 9
  10. 10
  11. 11
  12. 12
  13. 13
  14. Arch

Standards

POSIX.1-2008.

History

4.4BSD, POSIX.1-2001.

strcasecmp() first appeared in 4.4BSD, where it was declared in <string.h>. Thus, for reasons of historical compatibility, the glibc <string.h> header file also declares this function, if the _DEFAULT_SOURCE (or, in glibc 2.19 and earlier, _BSD_SOURCE) feature test macro is defined.

The POSIX.1-2008 standard says of this function:

When the LC_CTYPE category of the locale being used is from the POSIX locale, these functions shall behave as if the strings had been converted to lowercase and then a byte comparison performed. Otherwise, the results are unspecified.

From man-pages 6.19-1 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.