| 1 |
'\" t |
| 2 |
.\" Copyright, the authors of the Linux man-pages project |
| 3 |
.\" |
| 4 |
.\" SPDX-License-Identifier: Linux-man-pages-copyleft |
| 5 |
.\" |
| 6 |
.TH strchrnul 3 2026-02-25 "Linux man-pages 6.18" |
| 7 |
.SH NAME |
| 8 |
strchrnul \- string search character or NUL |
| 9 |
.SH LIBRARY |
| 10 |
Standard C library |
| 11 |
.RI ( libc ,\~ \-lc ) |
| 12 |
.SH SYNOPSIS |
| 13 |
.nf |
| 14 |
.BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */" |
| 15 |
.B #include <string.h> |
| 16 |
.P |
| 17 |
.BI "char *strchrnul(const char *" s ", int " c ); |
| 18 |
.fi |
| 19 |
.SH DESCRIPTION |
| 20 |
The |
| 21 |
.BR strchrnul () |
| 22 |
function is like |
| 23 |
.BR strchr (3) |
| 24 |
except that if |
| 25 |
.I c |
| 26 |
is not found in |
| 27 |
.IR s , |
| 28 |
then it returns a pointer to the null byte |
| 29 |
at the end of |
| 30 |
.IR s . |
| 31 |
.P |
| 32 |
It is equivalent to both of the following expressions: |
| 33 |
.P |
| 34 |
.in +4n |
| 35 |
.EX |
| 36 |
strchr(s, c) ?: strnul(s) |
| 37 |
s + strcspn(s, (char [2]){c, \[aq]\[rs]0\[aq]}) |
| 38 |
.EE |
| 39 |
.in |
| 40 |
.SH RETURN VALUE |
| 41 |
The |
| 42 |
.BR strchrnul () |
| 43 |
function returns a pointer to the matched character, |
| 44 |
or a pointer to the null byte at the end of |
| 45 |
.I s |
| 46 |
if the character is not found. |
| 47 |
.SH ATTRIBUTES |
| 48 |
For an explanation of the terms used in this section, see |
| 49 |
.BR attributes (7). |
| 50 |
.TS |
| 51 |
allbox; |
| 52 |
lbx lb lb |
| 53 |
l l l. |
| 54 |
Interface Attribute Value |
| 55 |
T{ |
| 56 |
.na |
| 57 |
.nh |
| 58 |
.BR strchrnul () |
| 59 |
T} Thread safety MT-Safe |
| 60 |
.TE |
| 61 |
.SH STANDARDS |
| 62 |
GNU. |
| 63 |
.SH HISTORY |
| 64 |
glibc 2.1.1, |
| 65 |
FreeBSD 10, |
| 66 |
NetBSD 8. |
| 67 |
.SH SEE ALSO |
| 68 |
.BR string (3), |
| 69 |
.BR strchr (3), |
| 70 |
.BR strnul (3), |
| 71 |
.BR strcspn (3), |
| 72 |
.BR strspn (3) |