指针与数组
对于下面的代码,说法正确的是____。
|
1
2
3
4
5
6
|
char* s1 = "Hello world";char s2[] = "Hello world";s1[2] = 'E'; // 1s2[2] = 'E'; // 2*(s1 + 2) = 'E'; // 3*(s2 + 2) = 'E'; // 4
|
指针指向字符串时,字符串是常量,存储在常量区,而指针存储在栈区,不能对其操作修改。
求输出结果
|
1
2
3
|
int a[2][2][3]= { {{1,2,3},{4,5,6}},{{7,8,9},{10,11,12}}};int *ptr=(int *)(&a+1);printf(“%d %d”, *(int*)(a+1), *(ptr-1));
|
|
1
2
|
1. &a+i = a + i*sizeof(a); 2. a+i = a +i*sizeof(a[0]); |
浙公网安备 33010602011771号