Nettet7. mar. 2024 · The expression (&a + 1) is actually an address just after end of array ( after address of 5 ) because &a contains address of an item of size 5*integer_size and when we do (&a + 1) the pointer is incremented by 5*integer_size. ptr is type-casted to int * so when we do ptr -1, we get address of 5 Nettet2. jan. 2024 · int *p:只是说明了p是一个指针变量,但是这个指针指向了哪里并不知道。*p = a //=右边的意思是有一个变量a,取出当前a的值赋值给=号左边, =号左边的意思是我指向了一个地址你可以告诉我=右边是多少了,我给你保存到这个地址,下次你想用就到这个地 …
c语言笔记--------指针_QQQ心心QQQ的博客-CSDN博客
Nettet6. jan. 2024 · int a[] = {5,15,34,54,14,2,52,72}; int *p = &a[5]; 则p[2]的值为? //老师给的答案是54 我很摸不着头脑! 这个int *p = &a[5] 是理解成 定义一个指针变量 把数组变量a中第六个单元(值为2)的地址给这个指针变量p吗? //*p==2 ??? 求大神解惑! 谢谢了! 查看完整描述 7 回答 已采纳 Xyino_Snake TA贡献31条经验 获得超22个赞 我认为你给出的 … Nettet31. mar. 2014 · 4 Answers Sorted by: 5 Those two are the same : int *p; // declaration p = &a; // assignment and in the other you are combining the two steps together into one: int *p=&a; // declaration and assignment And if you have some compiler optimizations ON, the compiler might combine the two steps. Share edited Mar 31, 2014 at 17:13 islands trust mayne island bylaws
int *p=(int *)(&a+1),*(p-1)超详细解释 - CSDN博客
Nettet总结:int *p; 变量名叫p,类型为int *,可存放一个int数据的地址 。 注意: 这块的可存放一个int数据的地址,不是存放一个地址,是int类型 例如: int a = 5; int *p; p = &a; 这里a是一个int类型的变量,存放的int类型的数值5 &a 取到了存放int类型a的地址 p = &a; 把int类型a的地址赋给了int *类型的p 即就是int *类型的变量可存放一个int数据的地址 四. 指 … Nettetp是一个 指针变量 ,它指向包含5个int元素的一维数组, 此时p的增量以它所指向的一维数组长度为单位; p+i是一维数组a [i]的地址,即p+i==&a [i];对该式两边作取内容运算(*)得* (p+i)==a [i],由于二维数组中a [i]==&a [i] [0],则* (p+i)表示a [i] [0]的地址,即* (p+i)==&a [i] [0]; * (p+2)+3表示a [2] [3]地址(第一行为0行,第一列为0列),*(* … Nettet若有以下语句: int a[4][5],(*p)[5] p=a表示指针变量p指向了这个二维数组对象,p的值也就是这个二维数组对象的首地址,对p进行步长加减计算,相当于指针指向某一行数组对象,也就是表示了这个步长计算的值为某一行数组对象的地址。 key west ballistic 281