| 1 |
'\" t |
| 2 |
.\" Copyright 1993 David Metcalfe ([email protected]) |
| 3 |
.\" |
| 4 |
.\" SPDX-License-Identifier: Linux-man-pages-copyleft |
| 5 |
.\" |
| 6 |
.\" References consulted: |
| 7 |
.\" Linux libc source code |
| 8 |
.\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991) |
| 9 |
.\" 386BSD man pages |
| 10 |
.\" Modified Sat Jul 24 17:57:50 1993 by Rik Faith ([email protected]) |
| 11 |
.TH strspn 3 2024-05-02 "Linux man-pages 6.9.1" |
| 12 |
.SH NAME |
| 13 |
strspn, strcspn \- get length of a prefix substring |
| 14 |
.SH LIBRARY |
| 15 |
Standard C library |
| 16 |
.RI ( libc ", " \-lc ) |
| 17 |
.SH SYNOPSIS |
| 18 |
.nf |
| 19 |
.B #include <string.h> |
| 20 |
.P |
| 21 |
.BI "size_t strspn(const char *" s ", const char *" accept ); |
| 22 |
.BI "size_t strcspn(const char *" s ", const char *" reject ); |
| 23 |
.fi |
| 24 |
.SH DESCRIPTION |
| 25 |
The |
| 26 |
.BR strspn () |
| 27 |
function calculates the length (in bytes) of the initial |
| 28 |
segment of |
| 29 |
.I s |
| 30 |
which consists entirely of bytes in |
| 31 |
.IR accept . |
| 32 |
.P |
| 33 |
The |
| 34 |
.BR strcspn () |
| 35 |
function calculates the length of the initial |
| 36 |
segment of |
| 37 |
.I s |
| 38 |
which consists entirely of bytes not in |
| 39 |
.IR reject . |
| 40 |
.SH RETURN VALUE |
| 41 |
The |
| 42 |
.BR strspn () |
| 43 |
function returns the number of bytes in |
| 44 |
the initial segment of |
| 45 |
.I s |
| 46 |
which consist only of bytes |
| 47 |
from |
| 48 |
.IR accept . |
| 49 |
.P |
| 50 |
The |
| 51 |
.BR strcspn () |
| 52 |
function returns the number of bytes in |
| 53 |
the initial segment of |
| 54 |
.I s |
| 55 |
which are not in the string |
| 56 |
.IR reject . |
| 57 |
.SH ATTRIBUTES |
| 58 |
For an explanation of the terms used in this section, see |
| 59 |
.BR attributes (7). |
| 60 |
.TS |
| 61 |
allbox; |
| 62 |
lbx lb lb |
| 63 |
l l l. |
| 64 |
Interface Attribute Value |
| 65 |
T{ |
| 66 |
.na |
| 67 |
.nh |
| 68 |
.BR strspn (), |
| 69 |
.BR strcspn () |
| 70 |
T} Thread safety MT-Safe |
| 71 |
.TE |
| 72 |
.SH STANDARDS |
| 73 |
C11, POSIX.1-2008. |
| 74 |
.SH HISTORY |
| 75 |
POSIX.1-2001, C89, SVr4, 4.3BSD. |
| 76 |
.SH SEE ALSO |
| 77 |
.BR memchr (3), |
| 78 |
.BR strchr (3), |
| 79 |
.BR string (3), |
| 80 |
.BR strpbrk (3), |
| 81 |
.BR strsep (3), |
| 82 |
.BR strstr (3), |
| 83 |
.BR strtok (3), |
| 84 |
.BR wcscspn (3), |
| 85 |
.BR wcsspn (3) |