Returns the length of a wide string, that is the number of non-null wide characters that precede the terminating null wide character.
The behavior is undefined if there is no null character in the wide character array pointed to by str.
[edit] Parameters str - pointer to the null-terminated wide string to be examined [edit] Return valueThe length of the null-terminated wide string str.
[edit] Possible implementationstd::size_t wcslen(const wchar_t* start) { // NB: start is not checked for nullptr! const wchar_t* end = start; while (*end != L'\0') ++end; return end - start; }[edit] Example
#include <iostream> #include <cwchar> int main() { const wchar_t* str = L"Hello, world!"; std::wcout << "The length of L\"" << str << "\" is " << std::wcslen(str) << '\n'; }
Output:
The length of L"Hello, world!" is 13[edit] See also
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4