wcslen() — Calculate length of wide-character string
Standards
Standards / Extensions | C or C++ | Dependencies |
---|---|---|
ISO C Amendment |
both |
Format
#include <wchar.h> /* or #include <wcstr.h> */
size_t wcslen(const wchar_t *string);
General description
Computes the number of wide characters in the string pointed to by string.
The behavior of this wide-character function is affected by the LC_CTYPE category of the current locale. If you change the category, undefined results can occur.
Returned value
wcslen() returns the number of wide characters that precede the terminating wide NULL character.
Example
CELEBW12
/* CELEBW12
This example computes the length of a wide-character string,
using &wcslen.
*/
#include <stdio.h>
#include <wchar.h>
int main(void)
{
wchar_t * string = L"abcdef";
printf( "Length of \"%ls\" is %i\n", string, wcslen( string ));
}
Output:
Length of "abcdef" is 6