strcasecmp(3)

โœจ strcasecmp(3) โœจ

ok so bestie, this one's from the Library Functions Manual and it's literally the โœจvibe-basedโœจ way to compare strings. no cap.


๐Ÿ’– NAME ๐Ÿ’–

strcasecmp โ€” strings case-insensitive compare

like. it compares strings. but it does NOT care about your capitalization. periodt.


๐Ÿ“š LIBRARY ๐Ÿ“š

Standard C library (libc, -lc)

that's the one you already got, bestie, nothing extra to install ๐Ÿซถ


๐ŸŽ€ SYNOPSIS ๐ŸŽ€

#include <strings.h>

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

yes the header is strings.h with an s, not string.h. i know. i KNOW. we'll get to that in HISTORY, it's messy ๐Ÿ™ˆ


๐ŸŒธ DESCRIPTION ๐ŸŒธ

okay so strcasecmp() does a byte-by-byte comparison of the strings s1 and s2, and while it's doing that it's completely ignoring the case of the characters. like "HELLO" and "hello" walk in and it's giving โœจsame girlโœจ.

It returns an integer that is:

  • less than zero โ†’ s1 is found to be less than s2
  • equal to zero โ†’ s1 matches s2
  • greater than zero โ†’ s1 is found to be greater than s2

that's it, that's the whole function, she's simple and she ate ๐Ÿ”ฅ


๐Ÿ’… RETURN VALUE ๐Ÿ’…

strcasecmp() returns an integer that is less than, equal to, or greater than zero if s1 is (after ignoring case, bestie, don't forget) found to be less than, to match, or greater than s2, respectively.

respectively. i said what i said ๐Ÿ’…


๐Ÿฆ‹ ATTRIBUTES ๐Ÿฆ‹

for the explanation of the terms used in this section, go peek at attributes(7). ๐Ÿ’œ

  • Interface: strcasecmp()
  • Attribute: Thread safety
  • Value: MT-Safe locale

so she is MT-Safe locale, which means she's out here being thread-safe but her behaviour depends on your locale. iykyk ๐ŸŒˆ


๐Ÿ‘‘ STANDARDS ๐Ÿ‘‘

POSIX.1-2008.

certified iconic, on the official list, no notes โญ


๐ŸŒˆ HISTORY ๐ŸŒˆ

4.4BSD, POSIX.1-2001.

strcasecmp() first appeared in 4.4BSD, where it was declared in <string.h>.

so here's the tea ๐Ÿ“: for reasons of historical compatibility, the glibc <string.h> header file also declares this function โ€” but only if the _DEFAULT_SOURCE feature test macro is defined (or, in glibc 2.19 and earlier, _BSD_SOURCE).

so if you're like "why is it working and i didn't include strings.h" โ€” that's why, bestie. feature test macros, we love a plot twist ๐Ÿ˜ญ

and then the POSIX.1-2008 standard says this about it, and i'm quoting it directly because this part is a whole mood:

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.

"otherwise, the results are unspecified" โ€” that's the standard saying good luck bestie ๐Ÿ’€ so heads up: outside the POSIX locale, don't be out here assuming anything.


๐Ÿ” SEE ALSO ๐Ÿ”


that's the whole page!! go forth and compare strings case-insensitively, you absolute main character ๐Ÿ‘‘๐Ÿ’–

this lil writeup is from Linux man-pages 6.20, dated 2026-08-10, and it's still serving strcasecmp(3) realness ๐ŸŽ€โœจ

๐Ÿ“ฆ where this page comes from
  • arch rolling: man-pages 6.20-1 ยท BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
  • nixpkgs unstable: man-pages 6.20
  • ๐Ÿ“œ the page's license: Linux-man-pages-copyleft
  • ๐Ÿ’– girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms