6.23.39 wcslen Function

Determines the length of a wide string.

Attention: This function is implemented only by MPLAB XC32 C compilers.

Include

<wchar.h>

Prototype

size_t wcslen(const wchar_t * s);

Arguments

s
the wide string

Return Value

Returns the nummber of wide characters present in the string, excluding the terminating null wide character.

Example

See the notes at the beginning of this chapter or section for information on using printf() or scanf() (and other functions reading and writing the stdin or stdout streams) in the example code.

#include <wchar.h>

int main(void)
{
  wchar_t ws1[20] = L"We are here";
  wchar_t ws2[20] = L"";
  wchar_t ws3[20] = L"Why me?";

  wprintf(L"ws1 : %ls\n", ws1);
  wprintf(L"\t(wsing length = %d characters)\n\n", wcslen(ws1));
  wprintf(L"ws2 : %ls\n", ws2);
  wprintf(L"\t(wsing length = %d characters)\n\n", wcslen(ws2));
  wprintf(L"ws3 : %ls\n", ws3);
  wprintf(L"\t(wsing length = %d characters)\n\n\n", wcslen(ws3));

}

Example Output

ws1 : We are here
	(wsing length = 11 characters)

ws2 : 
	(wsing length = 0 characters)

ws3 : Why me?
	(wsing length = 7 characters)