strchrnul(3)

strchrnul3

String search character or nul

Usage

#define _GNU_SOURCE  /* See feature_test_macros(7) */
#include <string.h>

char *strchrnul(const char *s, int c);

Library

Standard C library (libc, -lc)

Overview

The strchrnul() function is like strchr(3) except that if c is not found in s, then it returns a pointer to the null byte at the end of s.

It is equivalent to both of the following expressions:

strchr(s, c) ?: strnul(s)
s + strcspn(s, (char [2]){c, '\0'})

Return value

The strchrnul() function returns a pointer to the matched character, or a pointer to the null byte at the end of s if the character is not found.

Attributes

For an explanation of the terms used in this section, see attributes(7).

InterfaceAttributeValue
strchrnul()Thread safetyMT-Safe

Releases

11 releases since Debian 4.0 (Etch); the text changed 10 times.

  1. 4.0
  2. 5.0
  3. 6.0
  4. 7
  5. 8
  6. 9
  7. 10
  8. 11
  9. 12
  10. 13
  11. Arch

Standards

GNU.

History

glibc 2.1.1, FreeBSD 10, NetBSD 8.

From man-pages 6.19-1 in Arch Linux 2026-11-01. Parsed by carta from the page's man source.