可能重复:
strtok 不接受:char *str
使用该strtok
函数时,使用 achar *
而不是 achar []
会导致分段错误。
这运行正常:
char string[] = "hello world";
char *result = strtok(string, " ");
这会导致分段错误:
char *string = "hello world";
char *result = strtok(string, " ");
谁能解释导致这种行为差异的原因?