1#include <stdio.h>2#include <malloc.h>3 4 intMain ()5 {6 CharS1[] = {'H','e','1','2','o'};7 Char*p= (Char*) (s1+3);8printf"*p:%c\n"-P:0]);9 Char*p2= (Char*) (&s1[0]+4);Tenprintf"*p2:%c\n", p2[0]); One Char*p3= (Char*) (&s1+1); Aprintf"*p3:%c\n", p3[-1]); - - return 0; the}
Output:
*p:2
*p2:o
*p3:o
Before this, the array value is always unable to distinguish between the difference between the s1+2,&s1[0]+2,&s1+2, today deliberately tested under, the original their differences are as follows:
S1+2:
Refers to the value of 2-bit from the beginning of the S1 array 0 bits.
&s1[0]+2:
As with S1+2, the 2-bit value is moved down from the 0 bits of the S1 array.
Special Note: &s1+1:
Refers to moving to the next position of the S1 entire array, which is equivalent to moving out of the S1 array.
On the identification of the address of the array (&s+1,s+1,&s[0]+1)