wcslen, wcsnlen_s

Header: <wchar.h>

  1. Returns the length of a wide string, that is the number of non-null wide characters that precede the terminating null wide character.

# Declarations

size_t wcslen( const wchar_t *str );

(since C95)

size_t wcsnlen_s(const wchar_t *str, size_t strsz);

(since C11)

# Parameters

# Notes

strnlen_s and wcsnlen_s are the only bounds-checked functions that do not invoke the runtime constraints handler. They are pure utility functions used to provide limited support for non-null terminated strings.

# Example

#include <wchar.h>
#include <stdio.h>
 
int main(void)
{
    wchar_t str[] = L"How many wide characters does this string contain?";
 
    printf("without null character: %zu\n", wcslen(str));
    printf("with null character: %zu\n", sizeof str / sizeof *str);
}

# See also