C Language Pointer Elementary 2

Table of contents

1. Pointers and arrays

2. Secondary pointer

3. Array of pointers


1: pointers and arrays

different : 

    1: Pointer: A pointer is a pointer, which describes the address number of a space in our memory, and the unit byte. When we usually call a pointer, we generally refer to a pointer variable, which is used to store addresses.

        2: An array is an array. It is a collection of the same element type opened up in memory. The size of the space it opens up can be solved by the sizeof keyword, and the use of the address increases with the increase of the subscript, and the address of the array element will also increase. Increase.

connect:

        The array name is essentially the address of the first element of the array, except for two cases, 1: use sizeof (array name) 2: &arr, the entire address of the array is taken out, but the print is still the address of the first element, in other cases , are the address of the first element, we can see it through vs:

        Ever since, we can use pointers to accept array names and access arrays through pointers. like:

        

 

2: Secondary pointer

         Second-level pointer: We know that the first-level pointer is used to store the address of the variable and the name of the array, and the pointer we create also needs to apply for space in the memory, so there is the concept of the second-level pointer. The second-level pointer is essentially used To store the address of the first-level pointer,

Its syntax is: int**pp =&p, assuming that p is a pointer, and about int**pp, we understand it in this way. First, * represents a pointer, and int* represents that the type of variable pointed to is a pointer:

        We know that if int*pa =&a, *pa, we dereference pa, in fact, pa accesses a, and int**ppa, if we **ppa, first *ppa is used to access pa, *pa is a up.

3: Array of pointers

        Pointer arrays are essentially arrays. We know that integer arrays are used to store integers, and character arrays are used to store characters. Then pointer arrays can also be understood in this way. Pointer arrays are used to store pointers.

        Its grammatical form is: int* arr[]; here we know that [] means that arr is an array, and the int* in front means that each element in the array is an integer pointer type

        Let's implement it through some specific codes:

                

 

        The basic knowledge points of the pointer have been shared, thank you for watching, if you think it is useful to you, you can give it a thumbs up!

        The next article will be a preliminary explanation of the structure.

Guess you like

Origin blog.csdn.net/2201_75964502/article/details/130782578