strlen(3)

strlen3

Find length of string

Usage

#include <string.h>

size_t

strlen(const char *s);

size_t

strnlen(const char *s, size_t maxlen);

Library

Standard C Library (libc, -lc)

Overview

The strlen() function computes the length of the string s. The strnlen() function attempts to compute the length of s, but never scans beyond the first maxlen bytes of s.

Return values

The strlen() function returns the number of characters that precede the terminating NUL character. The strnlen() function returns either the same result as strlen() or maxlen, whichever is smaller.

Releases

163 releases since Mac OS X 10.0; the text changed 2 times.

  1. 10.0–10.1.5
  2. 10.2–10.6.8
  3. 10.7–26.5

Standards

The strlen() function conforms to ISO/IEC 9899:1990 (“ISO C90”). The strnlen() function conforms to IEEE Std 1003.1-2008 (“POSIX.1”).

From Libc 1752.120.2 in macOS 26.5. Parsed by carta from the page's mdoc source.