Hi, the examples section of wcstok(3) shows the following code which exhibits undefined behaviour and typically segfaults: <https://man7.org/linux/man-pages/man3/wcstok.3.html#EXAMPLES> | wchar_t *wcs = ...; | wchar_t *token; | wchar_t *state; | for (token = wcstok(wcs, " \t\n", &state); | token != NULL; | token = wcstok(NULL, " \t\n", &state)) { | ... | } The string literal pointed to by wcs is read-only, and an attempt to modify a string literal results in undefined behaviour; wcstok() but writes NULs into its input string. FIX: replace the first line with either | wchar_t *wcs = strdup(...); or | wchar_t wcs[] = ...; regards Stefan