因为字符串 和字符串数组 是有点区别的 比如说 char str[8] = "qwe asd"; 这个时候你可以用 str[0] = 'c';来进行赋值 而 char str = “qwe asd” ; 这个时候你可以调用str[0]进行输出,但是str[0] = 'c';这样的赋值是非法的,会有未指定入口的错误提示 所以你的 str[i++]=*p;这里会运行不下去,因为你传进函数的是字符串,而不是字符串数组 我这样写的,你看看跟你原来的想法有什么不同 #include #include #include #include void fun(char *str); int main() { char str[8]="a bcd"; fun(str); cout<