STRLEN(3)

NAME
strlen, strnlen - find length of a string

SYNOPSIS
#include <string.h>
size_t
strlen(const char *s);
size_t
strnlen(const char *s, size_t maxlen);

DESCRIPTION
The strlen() function computes the length of the string s.

The strnlen() function computes the length of the string s, up to maxlen characters. The strnlen() function will never attempt to address more than maxlen characters, making it suitable for use with character arrays that are not guaranteed to be NUL-terminated.

RETURN VALUES
The strlen() function returns the number of characters that precede the terminating NUL character.

The strnlen() function returns the number of characters that precede the terminating NUL or maxlen, whichever is smaller.

SEE ALSO
string(3), wcslen(3)

STANDARDS
The strlen() function conforms to ansiC.

The strlen() and strnlen() functions conform to p1003.1-2008.

HISTORY
The strlen() function first appeared in the Programmer's Workbench (PWB/UNIX) and was ported to AT&T UNIX. The strnlen() function appeared in glibc 2.0 and was reimplemented for OpenBSD 4.8.