STRCSPN(3POSIX)
π STRCSPN β the strcspn(3POSIX) page, bestie edition π
okay so real talk: this is a page from the POSIX Programmer's Manual, and I'm about to make it make sense. grab a strawberry π and let's go.
β¨ PROLOG β¨ (the lil disclaimer)
okay so first things first, bestie, this manual page is part of the POSIX Programmer's Manual. but here's the tea:
the Linux implementation of this interface may differ β so like, consult the corresponding Linux manual page for details on Linux behavior β or the interface may not even be implemented on Linux at all. π so don't come for me if Linux does its own thing.
πΈ NAME πΈ
strcspn β get the length of a complementary substring
(iconic name, no notes. it's giving "span, but make it complementary" π )
π SYNOPSIS π
#include <string.h>
size_t strcspn(const char *s1, const char *s2);
two strings walk in, one size_t walks out. slay.
π¦ DESCRIPTION π¦
so the functionality described on this reference page is aligned with the ISO C standard. and like, any conflict between the requirements described here and the ISO C standard? unintentional, fr fr. this volume of POSIX.1β2017 defers to the ISO C standard. periodt.
now the actual vibe:
the strcspn() function shall compute the length (in bytes) of the maximum initial segment of the string pointed to by s1 which consists entirely of bytes not from the string pointed to by s2.
translation for the girlies: it walks along s1 from the start, counting bytes, and stops the moment it hits a byte that shows up in s2. the count before that moment? that's your answer. main character energy for s1, and s2 is literally just the list of dealbreakers. π
π₯ RETURN VALUE π₯
the strcspn() function shall return the length of the computed segment of the string pointed to by s1.
and listen β no return value is reserved to indicate an error. like, there's no secret error code hiding in there. it's just the number. that's it. that's the whole thing. π«Ά
π ERRORS π
No errors are defined.
and then it says: the following sections are informative. so like, everything after this is bonus content, not rules. noted. β¨
π EXAMPLES π
None.
(it said what it said π )
π APPLICATION USAGE π
None.
(nothing to add, bestie, it's a self-explanatory baddie)
β RATIONALE β
None.
(no reasoning needed, it simply is. icon behavior.)
π§ FUTURE DIRECTIONS π§
None.
(future's looking stable, we love that for us)
πΈ SEE ALSO πΈ
strspn()- The Base Definitions volume of POSIX.1β2017,
<string.h>
like yeah, go read strspn() β it's the non-complementary sibling. they're a set, iykyk. π
π COPYRIGHT π
okay so legal girlies, here's the whole thing verbatim because we do NOT skip the fine print:
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
and that's the whole page, bestie!! π«Ά this absolute classic was brought to you by IEEE / The Open Group, dated 2017, under the manual name STRCSPN(3POSIX). go count some bytes responsibly. π
β¨
π¦ where this page comes from
- debian bookworm: manpages-posix-dev 2017a-2 Β· Other
- debian trixie: manpages-posix-dev 2017a-2 Β· Other
- ubuntu jammy: manpages-posix-dev 2017a-2 Β· Other
- ubuntu noble: manpages-posix-dev 2017a-2 Β· Other
- ubuntu resolute: manpages-posix-dev 2017a-2build1 Β· Other
- ubuntu stonking: manpages-posix-dev 2017a-2.1 Β· Other
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms