Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - How to do this problem in C language? After p becomes a one-dimensional integer pointer array, it is not clear whether p+ 1 represents an array element or a p array element address.
How to do this problem in C language? After p becomes a one-dimensional integer pointer array, it is not clear whether p+ 1 represents an array element or a p array element address.
A is an array of 2×3=6 integers with 2 rows and 3 columns, but P is a pointer to an array of 3 elements.

The following procedures verify the referenced results;

# Contains? " stdio.h "

int? Master ()

{

int? a[2][3]={ 1,2,3,4,5,6},(*p)[3],I;

p = a;

printf(" *(p+2)= % u \ n " ,*(p+2));

printf("p[2]=%u\n ",p[2]);

printf(" p[ 1]+ 1 = % u \ n ",p[ 1]+ 1);

printf("(p+ 1)+2=%u\n ",(p+ 1)+2);

Printf ("address? Are you online? p:\ n ");

For what? (I = 0; I<3; i++)? printf("p[%d]=%u,value=%d\n ",I,p[i],* p[I]);

Printf ("address? Yes? a=%u\n ",a);

System ("suspended");

Return? (0);

}p[0] is the first address of array A, pointing to the first row of the array. The array has three elements, and each integer occupies 2 bytes (address);

P[ 1] is the first address in the second row of array A, and it also has three elements. 65480-65474=6, which is the storage address of three integers.

Array A has six elements and only two rows. P[2] is already the first address after array A and does not belong to array A. ..

*(p+2)=p[2], which is the first address after array A and does not belong to array A. ×

P[2] is the first address after array A and does not belong to array A..×

P[ 1]+ 1 is the address of the second element in the second row of array A, which is a correct reference. √

(p+ 1)+2, which means p+3, even in A ×