---
name: "strchrnul"
section: "3"
platform: "linux"
package: "man-pages"
version: "6.19-1"
release: "Arch Linux 2026-11-01"
platforms: ["linux", "freebsd"]
url: "https://new.carta.tech/strchrnul"
---

# strchrnul(3)

string search character or NUL

## NAME

strchrnul - string search character or NUL

## LIBRARY

Standard C library (*libc*, *-lc*)

## SYNOPSIS

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

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

## DESCRIPTION

The **strchrnul**() function is like [**strchr**(3)](/strchr/3.md) 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)](/attributes/7.md).

| | | |
| --- | --- | --- |
| **Interface** | **Attribute** | **Value** |
| **strchrnul**() | Thread safety | MT-Safe |

## STANDARDS

GNU.

## HISTORY

glibc 2.1.1, FreeBSD 10, NetBSD 8.

## SEE ALSO

[**string**(3)](/string/3.md), [**strchr**(3)](/strchr/3.md), [**strnul**(3)](/strnul/3.md), [**strcspn**(3)](/strcspn/3.md), [**strspn**(3)](/strspn/3.md)
