A pointer is a variable whose value is a memory address, and the core of the pointer is that it is a variable, except that it is used to store memory addresses. Before you get to the pointers, let's talk about what variables are. A variable is a space that opens up in memory. such as int year, is to open up a space in memory, space name for year, what to open up space to do? It must be what is needed to keep the program running, and in the computer language, the storage is assigned. Year= 2018, assigns a value to year, that is, in year this space holds an integer 2018; Opens up space and stores values, so what do we do with this space? How can we find this space? Of course, the simplest way is to use the name of the year, in fact, there is a way to find the address of this space, find the address, we can do anything. Memory in the open space, it will automatically have an address, this address is the memory address, this and our daily life is the same truth. For example, the developer took a piece of land, it is equivalent to open up space. Take the land at the same time, that is, the opening of space, it will automatically have an address, he took in Guangdong province, the address must be Guangdong province, not Beijing, and the address will not change again. But the address description way is different, in the real life, it is Guangdong province Shenzhen Chun, but in the computer, it is a hexadecimal numeral hair, oXc522;
Each variable has an address, we want to manipulate the address, we need to get the address and save it, save the thing is to use variables, this variable to save the memory address, so a name is a pointer. The declaration of a pointer variable is also different, with a * declaration. int *point_year. How to get the variable address with & &year to get the year memory address, then it can assign the group Point_year variable. Point_year = &year, Point_year holds the memory address of year, so it can also be called point_year pointing to year. Here there is a constant of the number, NULL, represented as NULL, such as Point_year = NULL, indicating that the pointer does not point to any address.
When * as an operator, called the value corresponding to the address, so it can only be placed in front of the pointer variable, take out the value pointed to the address, that is the variable. The value of *point_year is the variable year. *point_year = 10; It's actually about the amount of year assignment.
Pointer variable is also a variable, so it also has an address, &point_year is to take the pointer variable corresponding address. It is an address, so also declare a pointer variable int *ptr_ptr_year = &point_year. Then our * operator can also take address *ptr_ptr_year return is point_year, but it is also a pointer variable, *point_year is the variable to point to. The **ptr_ptr_year batch to year, **ptr_ptr_year = 10, is also given its variable year assignment.
C Language-----Pointers