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 โ
s1is found to be less thans2 - equal to zero โ
s1matchess2 - greater than zero โ
s1is found to be greater thans2
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
- Copyright 1993, David Metcalfe <david@prism.demon.co.uk>
- ๐ girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms