// filename:c2011-7-29-4-5-7-ex.c
// original examples and/or notes:
// 		(c) ISO/IEC JTC1 SC22 WG14 N1570, April 12, 2011
// 			C2011 7.29.4.5.7 The wcstok function
// compile and output mechanism:
// 		(c) Ogawa Kiyoshi, kaizen@gifu-u.ac.jp, December.29, 2013
// compile errors and/or wornings:
// 		(c) Apple LLVM version 4.2 (clang-425.0.27) (based on LLVM 3.2svn)
// 			Target: x86_64-apple-darwin11.4.2 //Thread model: posix
// 		(c) LLVM 2003-2009 University of Illinois at Urbana-Champaign.
#include <stdio.h>
#include <wchar.h>

int main(void)
{
// Example

static wchar_t str1[] = L"?a???b,,,#c";
static wchar_t str2[] = L"\t \t";
wchar_t *t, *ptr1, *ptr2;
t = wcstok(str1, L"?", &ptr1); // t points to the token L"a"
	wprintf(L"%ls",t);
t = wcstok(NULL, L",", &ptr1); // t points to the token L"??b"
		wprintf(L"%ls",t);
t = wcstok(str2, L" \t", &ptr2); // t is a null pointer
		wprintf(L"%ls",t);
t = wcstok(NULL, L"#,", &ptr1); // t points to the token L"c"
		wprintf(L"%ls",t);
t = wcstok(NULL, L"?", &ptr1); // t is a null pointer
	wprintf(L"%ls\n",t);
return printf("7.29.4.5.7 The wcstok function\n");
}
// output may be 
// a??b(null)c(null)
// 7.29.4.5.7 The wcstok function