[Previous] [Contents] [Next]

wcstok()

Break a string into tokens

Synopsis:

#include <wchar.h>

wchar_t * wcstok( wchar_t * ws1,
                  const wchar_t * ws2,
                  wchar_t ** ptr );

Library:

libc

Description:

The function wcstok() breaks the string pointed to by ws1 into a sequence of tokens, each of which is delimited by a wide character from the string pointed to by ws2. The ptr argument points to a user-provided pointer, which points to stored information necessary for wcstok() to continue scanning the same string.

In the first call to wcstok(), ws1 must point to a null-terminated string, ws2 points to a null-terminated string of separator wide characters, and ptr is ignored. The wcstok() function returns a pointer to the first wide character of the first token, writes a NUL wide character into ws1 immediately following the returned token, and updates ptr.

In subsequent calls, ws1 must be a NULL pointer and ptr must be unchanged from the previous call so that subsequent calls will move through the string ws1, returning successive tokens until no tokens remain. The separator string ws2 may differ from call to call. When no tokens remain in ws1, a NULL pointer is returned.

Returns:

NULL
Failure; no token found.
x
Success; pointer to first wide character of token.

Classification:

POSIX 1003.1

wcstok()

Safety:
Cancellation point No
Interrupt handler No
Signal handler Yes
Thread Yes

See also:

"String manipulation functions" and "Wide-character functions" in the summary of functions chapter.


[Previous] [Contents] [Next]