wcslen() — Calculate Length of Wide-Character String

Format

#include <wchar.h>
size_t wcslen(const wchar_t *string);

Language Level: XPG4

Threadsafe: Yes.

Wide Character Function: See Wide Characters for more information.

Description

The wcslen() function computes the number of wide characters in the string pointed to by string.

Return Value

The wcslen() function returns the number of wide characters in string, excluding the ending wchar_t null character.

Example that uses wcslen()

This example computes the length of the wide-character string string.

#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 should be similar to:  ******************
 
Length of "abcdef" is 6
*/

Related Information



[ Top of Page | Previous Page | Next Page | Contents | Index ]