Through the previous article, we have a basic understanding of pointers , I see. It's just something with an address , But the use of relative pointers , I'll talk again about the basic uses of pointers ;

         Pointer operation :

The pointer can also be ++,-- perhaps +,- Operation of , But the budget of the pointer is limited to this ,++,+ Represents that the pointer moves forward ,--,-
Represents a backward movement of the pointer . It also refers to the forward or backward address it refers to ;

        Like the next program :
int a[10]; int *p; p = &a; //p point a array i = 0; for(i;i<10;i++) {
printf("%p",p);// Output now p Position indicated P ++; //p Add one to the indicated position }
        This program outputs a Address of items in the array ;

When the address of an array is given to a pointer , When this pointer refers to
a【0】 Address of , That is, the address of the first number in the array , Because of the array arrangement , The given location space in memory is continuous , So when we add one to the value indicated by the pointer , That means pointing to the next address in the array ;

         Relational operation of pointer :

Relationship between two pointers , Size, etc , The comparison refers to the relationship between the addresses , And the size of the address , By ASC|| Code ; It's like :

int a,*p,*d;

*p = &a;

When in this case

We say    *p == *d; This would be a fake ;

*d = &a;     

*p == *d;

under these circumstances , This will be true , Only when two pointers point to one address at the same time , Then the two pointers can be said to be equal .

         Relationship between pointer and array :

Next, let's focus on the relationship between pointers and arrays , How do they use each other ;

As we mentioned above , When the pointer points to a one-dimensional array , The address it refers to is the address of the first value of the array , When the pointer is performing an operation +, - Hour , Corresponding , The address it refers to will also change ;

When the pointer points to a multidimensional array , In fact, it is similar to pointing to a one-dimensional array , The changes were like this

a【2】【2】; In this array , We let *p=&a;

initial p Is pointing a【0】【0】;

When p++ Hour , Will point to a【0】【1】; Next is a【0】【2】;a【1】【0】;a【1】【1】; and so on ;

about int a【3】【4】,*p = a【0】;

Address description meaning the description meaning of array elements
a,*a,a【0】,&a【0】【0】,pa First address of **a,*p,*a【0】,          a【0】【0】a【0】【0】 Value of
*a+1,a【0】+1,&a【0】【0】+1,p+1a【0】【1】 Address of *(*a+1),*(p+1),    a【0】【1】,               
           *{a【0】+1),               *(&a【0】【0】+1a【0】【1】 Value of
a+1a【1】【0】 Address of
**(a+1),*a【1】,a【1】【0】
a【1】【0】 Value of
a+ia【i】【0】 Address of **(a+i),*a【i】,              a【i】【0】a【i】【0】 Value of
*a+ix4+j,p+ix4+j,a【0】+ix4+j,&a【0】【0】+ix4+j,&a【i】【j】a【i】【j】 Address of
*(*a+ix4+j),*(p+ix4+j),   *(a【0】+ix4+j),        a【i】【j】,*(&a【0】【0】+ix4+j)
a【i】【j】 Value of
 

Through this table , We can basically have a more comprehensive understanding of the relationship between pointers and multidimensional arrays .

notes : For clarity of Blog , I use 【】 instead of [] , Don't learn from me , Use English input method .

Technology