strchr(3)

strchr3

Locate character in string

Usage

#include <string.h>

QChar *

strchr(QChar *s, int c);

QChar *

strrchr(QChar *s, int c);

QChar *

strchrnul(QChar *s, int c);

Library

Standard C Library (libc, -lc)

Overview

The strchr() function locates the first occurrence of c (converted to a char) in the string pointed to by s. The terminating null character is considered part of the string; therefore if c is ‘\0’, the functions locate the terminating ‘\0’.

The strrchr() function is identical to strchr() except it locates the last occurrence of c.

The strchrnul() function is identical to strchr() except that if c is not found in s a pointer to the terminating ‘\0’ is returned.

Return values

The functions strchr() and strrchr() return a pointer to the located character, or NULL if the character does not appear in the string.

strchrnul() returns a pointer to the terminating ‘\0’ if the character does not appear in the string.

Releases

87 releases since FreeBSD 2.0.5-RELEASE; the text changed 46 times.

  1. 2.0.5–2.2.5
  2. 2.2.6–3.4
  3. 3.5–3.5.1
  4. 4.0
  5. 4.1–4.2
  6. 4.3–4.4
  7. 4.5–4.8
  8. 4.9
  9. 4.10–4.11
  10. 5.0
  11. 5.1
  12. 5.2–5.5
  13. 6.0–6.3
  14. 6.4
  15. 7.0
  16. 7.1
  17. 7.2
  18. 7.3
  19. 7.4
  20. 8.0
  21. 8.1
  22. 8.2
  23. 8.3
  24. 8.4
  25. 9.0
  26. 9.1
  27. 9.2
  28. 9.3
  29. 10.0
  30. 10.1
  31. 10.2
  32. 10.3
  33. 10.4
  34. 11.0
  35. 11.1
  36. 11.2
  37. 11.3
  38. 11.4
  39. 12.0
  40. 12.1
  41. 12.2
  42. 12.3
  43. 12.4
  44. 13.0–13.2
  45. 13.3–14.5
  46. 15.0–15.1
  47. 16.0

Standards

The functions strchr() and strrchr() conform to ISO/IEC 9899:2024 (“ISO C23”), where they are specified as qualifier-preserving functions.

The function strchrnul() is a GNU extension. Like the qualifier-preserving functions in ISO/IEC 9899:2024 (“ISO C23”), FreeBSD implements strchrnul() as qualifier-preserving as well.

History

The strchrnul() function first appeared in glibc 2.1.1 and was added in FreeBSD 10.0.

From base 16.0-CURRENT-20261027-61c70dc16a79 in FreeBSD 16.0-CURRENT (2026-10-27). Parsed by carta from the page's mdoc source.