@Артур352, я думаю ошибка в том, что третий аргумент должен быть адресом указателя, а у Вас NULL.
Я пишу в Linux-е, тут вместо виндовой strtok_s()
есть аналогичная функция strtok_r()
.
Вот пример с ней.
avp@avp-ubu1:~/hashcode$ cat strtok.c
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int
main (int ac, char *av[])
{
char *token, *saveptr,
*str = av[1] ? *(++av) : (char *)"xaxa xoxo xixi",
*strd = strdup(str);
const char *sep = av[1] ? av[1] : " ";
int i = 0;
str = strd;
printf ("source: [%s] separators: [%s]\n", str, sep);
while (token = strtok_r(str, sep, &saveptr)) {
printf ("token[%d] : <%s>\n", i++, token);
str = 0;
}
free(strd);
return puts("End") == EOF;
}
avp@avp-ubu1:~/hashcode$ g++ strtok.c
avp@avp-ubu1:~/hashcode$ ./a.out
source: [xaxa xoxo xixi] separators: [ ]
token[0] : <xaxa>
token[1] : <xoxo>
token[2] : <xixi>
End
avp@avp-ubu1:~/hashcode$ ./a.out " zqwe 223 , sy, ,sa,so , ," ", "
source: [ zqwe 223 , sy, ,sa,so , ,] separators: [, ]
token[0] : <zqwe>
token[1] : <223>
token[2] : <sy>
token[3] : <sa>
token[4] : <so>
End
avp@avp-ubu1:~/hashcode$ echo $?
0
avp@avp-ubu1:~/hashcode$
Что непонятно, спрашивайте