#include <stdio.h> #include <string.h> int main() { char *p = "he llo"; strtok(p," "); return 0; } 上面这个程序运行会出现段错误,我认为是p指针没有在堆中分配内存空间的原因,程序中只让p指向静态存储区存储的字符串“he llo”了,可能是strtok不能操作静态存储区数据的缘故吧。。。 #include <stdio.h> char* p = "Hello "; int main() { p[0] = 'X '; printf( "%s ", p); return 0; } 上面的程序通过指针修改常量也会出现段错误。