Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and beauty - Basic Pointer and Array Problems in C Language
Basic Pointer and Array Problems in C Language
The first question: int (* pz) [2]; Is to define an array pointer,

Second question: there is no format control character %p, so it is suggested to change it to printf ("pz =% d, pz+ 1 =% d \ n ",pz, pz+1); ? Get into a good habit. pz = zippo is to assign the first address of the zippo array to the pointer pz, and you can directly call printf(" Pz =% d, Pz+ 1 =% d \ n ",Pz, Pz+1); ? The output is the address of the array, not the value of the array. Pz corresponds to the address of 2 in the first element {2,4} of the array, and pz[0] is also the address of 2 in the first element {2,4} of the array, so it is equal, while pz+ 1 is the address of 6 in the second element {6,8} of the array, pz. Because the size of the array element is 2, your pz[0]+2 is equivalent to moving the pointer down one element!

The process is as follows:

# Contains? " stdio.h "

Invalid? Major (invalid)

{

int? zippo[4][2]={{2,4},{6,8},{ 1,3},{5,7 } };

int(* pz)[2];

pz = zippo

printf("pz=%d,pz+ 1=%d\n ",pz,pz+ 1);

printf("pz[0]=%d,pz[0]+2=%d\n ",pz[0],pz[0]+2);

}

Hope to adopt. Hee hee ...? Look at the results of the operation: