1./* XPG4 version of wcstok call */
#include <wchar.h>
#include <string.h>
#include <stdio.h>
main()
{
wchar_t str[] = L"...ab..cd,,ef.hi";
printf("|%S|\n", wcstok(str, L"."));
printf("|%S|\n", wcstok(NULL, L","));
printf("|%S|\n", wcstok(NULL, L",."));
printf("|%S|\n", wcstok(NULL, L",."));
}
2./* ISO C version of wcstok call */
#include <wchar.h>
#include <string.h>
#include <stdio.h>
main()
{
wchar_t str[] = L"...ab..cd,,ef.hi";
wchar_t *savptr = NULL;
printf("|%S|\n", wcstok(str, L".", &savptr));
printf("|%S|\n", wcstok(NULL, L",", &savptr));
printf("|%S|\n", wcstok(NULL, L",.", &savptr));
printf("|%S|\n", wcstok(NULL, L",.", &savptr));
}
Running this example produces the following results:
$ $ RUN WCSTOK_EXAMPLE
|ab|
|.cd|
|ef|
|hi|
$