Guardian Native C Library Calls Reference Manual (G06.28+, H06.04+)
Guardian Native C Library Calls (t - z) wcstok(3)
character strings, from call to call.
The implementation behaves as though no function calls the
wcstok() function.
EXAMPLES
The following example shows how to split a wide-character string into tokens.
#include <wchar.h>
#include <locale.h>
#include <stdio.h>
#define WLENGTH 40
main( )
{
wchar_t WCString1[WLENGTH], delimiters[WLENGTH];
wchar_t * pwcs;
int counter;
(void)setlocale(LC_ALL, "");
printf("Enter the string to be searched: ");
if (fgetws(WCString1, WLENGTH, stdin) != NULL) {
printf("Enter the delimiter(s): ");
if (fgetws(delimiters, WLENGTH, stdin) != NULL) {
if ((pwcs = wcstok(WCString1, delimiters ))
!= NULL) {
/* pwcs points to the first token */
printf("Token 1 is %S\n", pwcs);
counter = 2;
while ((pwcs = wcstok((wchar_t * )NULL, delimiters ))
!= NULL) {
printf("Token %d is %S\n", counter, pwcs);
counter++;
}
}
}
}
}
RETURN VALUES
Upon successful completion, the wcstok() function returns a pointer to the first wide character of
a token. A null pointer is returned if there is no token.
RELATED INFORMATION
Functions: strtok(3), wcspbrk(3), wcsspn(3), wcstod(3), wcstol(3), wcstoul(3).
527192-005 Hewlett-Packard Company 7−71