function
<cwchar>

wcslen

size_t wcslen (const wchar_t* wcs);
Get wide string length
Returns the length of the C wide string wcs.

This is the number of wide characters between wcs and the first null wide character (without including it).

This is the wide character equivalent of strlen (<cstring>).

Parameters

wcs
C wide string.

Return Value

The length of C wide string.

Example

1
2
3
4
5
6
7
8
9
10
11
12
/* wcslen example */
#include <stdio.h>
#include <wchar.h>

int main ()
{
  wchar_t wsInput[256];
  wprintf (L"Enter a sentence: ");
  fgetws ( wsInput, 256, stdin );  /* includes newline characters */
  wprintf (L"You entered %u characters.\n",wcslen(wsInput));
  return 0;
}

Output:

Enter sentence: just testing
You entered 13 characters.


See also