Name | Description | Notes | Source | Availability | |||||||
---|---|---|---|---|---|---|---|---|---|---|---|
strlen() |
Compute length of string | (·) | <string.h> |
C89 | C90 | C95 | C99 | C11 | |||
strnlen_s() |
Compute length of string | ? | (·) | <string.h> |
C11 | ||||||
wcslen() |
Compute length of wide-character string | (·) | <wchar.h> |
C95 | C99 | C11 | |||||
wcsnlen_s() |
Compute length of wide-character string | ? | (·) | <wchar.h> |
C11 |
#include <string.h>
size_t strlen(const char *s);
#define __STDC_WANT_ 1 #includeLIB_ EXT1__ <string.h>
size_t strnlen_s(const char *s, size_t n);
#include <wchar.h>
size_t wcslen(const wchar_t *s);
#define __STDC_WANT_ 1 #includeLIB_ EXT1__ <wchar.h>
size_t wcsnlen_s(const wchar_t *s, size_t n);
These functions compute the length of a string of bytes or wide
characters starting at s
by
finding the position of the first null terminator, and
returning it. strnlen_s
and wcsnlen_s
only search the first n
elements, and
return n
if no null character is
found. Also, strnlen_s(NULL, anything)
and wcsnlen_s(NULL, anything)
return zero.
Note that strlen
and strnlen_s
count bytes, not multibyte characters.