嗨,请向我解释为什么代码会产生错误,
#include<stdio.h>
int main(){
char ***x;
char **q = *x;
char **(*c) = x;
char ***d = &q;
char ***p = "asdasd";
x=p;
printf("d:%s\n",d);
printf("q:%s\n",q);
printf("x:%s\n",x);
return 0;
}
输出:1 分段错误
嗨,感谢您的回复,所以如果我初始化 x,我仍然遇到分段错误
printf("q:%s\n",q);
输出和代码如下所示,请告知为什么是 d:1231 而不是 1231123124 以及为什么 x=p 只改变 x 的值而不是 all (x, q, d)
int main(){
char ***x = "1231123124";
char **q = *x;
char **(*c) = x;
char ***d = &q;
char ***p = "asdasd";
x=p;
printf("p:%s\n",p);
printf("d:%s\n",d);
// printf("q:%s\n",q);
printf("x:%s\n",x);
printf("c:%s\n",c);
return 0;
}
输出:p:asdasd
d:1231
x:asdasd
联系人:1231123124