http://www.opengroup.org/onlinepubs/000095399/functions/strtok.html上给出的 strtok 程序每次都会崩溃。
#include <string.h>
...
char *token;
char *line = "LINE TO BE SEPARATED";
char *search = " ";
/* Token will point to "LINE". */
token = strtok(line, search);
/* Token will point to "TO". */
token = strtok(NULL, search);
如果我对变量“行”使用 char 数组,它可以工作。即 char line[] = "LINE TO BE SEPARATED" 有效。
请解释。