Name
wcslen
Synopsis
Obtains the length of a wide-character string
#include <wchar.h> size_twcslen
( const wchar_t *s
);
The wcslen()
function
calculates the length of the string addressed by its argument
s
. The length of a wide string is the
number of wide characters in it, not counting the terminating null
character (L'\0'
).
Example
wchar_t line[1024] =
L"This string could easily be 400 or 500 characters long. "
L"This string could easily be 400 or 500 characters long. "
L"\n";
wchar_t *readptr = line;
int columns = 80;
while (wcslen
( readptr ) > columns ) // While remaining text is too long,
{ // print a chunk with a final
wprintf( L"%.*ls\\\n", columns-1, readptr ); // backslash and newline.
readptr += columns -1;
}
wprintf( L"%ls\n", readptr ); // Print the rest, ending with a newline.
Get C in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.