The Single UNIX ® Specification, Version 2
Copyright © 1997 The Open Group

 NAME

wcstok - split wide-character string into tokens

 SYNOPSIS



#include <wchar.h>

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

 DESCRIPTION

A sequence of calls to wcstok() breaks the wide-character string pointed to by ws1 into a sequence of tokens, each of which is delimited by a wide-character code from the wide-character string pointed to by ws2. The third argument points to a caller-provided wchar_t pointer into which the wcstok() function stores information necessary for it to continue scanning the same wide-character string.

The first call in the sequence has ws1 as its first argument, and is followed by calls with a null pointer as their first argument. The separator string pointed to by ws2 may be different from call to call.

The first call in the sequence searches the wide-character string pointed to by ws1 for the first wide-character code that is not contained in the current separator string pointed to by ws2. If no such wide-character code is found, then there are no tokens in the wide-character string pointed to by ws1 and wcstok() returns a null pointer. If such a wide-character code is found, it is the start of the first token.

The wcstok() function then searches from there for a wide-character code that is contained in the current separator string. If no such wide-character code is found, the current token extends to the end of the wide-character string pointed to by ws1, and subsequent searches for a token will return a null pointer. If such a wide-character code is found, it is overwritten by a null wide-character, which terminates the current token. The wcstok() function saves a pointer to the following wide-character code, from which the next search for a token will start.

Each subsequent call, with a null pointer as the value of the first argument, starts searching from the saved pointer and behaves as described above.

The implementation will behave as if no function calls wcstok().

 RETURN VALUE

Upon successful completion, the wcstok() function returns a pointer to the first wide-character code of a token. Otherwise, if there is no token, wcstok() returns a null pointer.

 ERRORS

No errors are defined.

 EXAMPLES

None.

 APPLICATION USAGE

None.

 FUTURE DIRECTIONS

None.

 SEE ALSO

<wchar.h>.

UNIX ® is a registered Trademark of The Open Group.
Copyright © 1997 The Open Group
[ Main Index | XSH | XCU | XBD | XCURSES | XNS ]