My program looks like this:
我的程序看起来像这样:
char a[10];
char (*pa)[10];
pa = a;
a[0] = 'g';
*pa[1] = 'h';
printf("%c", *pa[0]);
printf("%c\n", *pa[1]);
a[0] = 'r';
a[1] = 'd';
printf("%c", *pa[0]);
printf("%c", *pa[1]);
When I run it I get the output:
当我运行它时,我得到输出:
gh
rh
How come the line
怎么回事
a[1] = 'd'
does not change the value to 'd'?
不会将值更改为“d”?
1 个解决方案
#1
0
you are assigning only value of a[0]
to *pa[0]
(there base addresses values) but not the value of second element.
您只将[0]的值分配给* pa [0](有基地址值),而不是第二个元素的值。
#1
0
you are assigning only value of a[0]
to *pa[0]
(there base addresses values) but not the value of second element.
您只将[0]的值分配给* pa [0](有基地址值),而不是第二个元素的值。