The pointer is a data type widely used in the C language. Using the pointer programming is one of the most important style of C language. The use of pointer variables can represent various data structures; it is convenient to use array and string; and can process memory addresses like assembly languages to compile the internal and efficient programs. The pointer greatly enriches the function of the C language. The learning pointer is the most important ring in the C language, and whether it can correctly understand and use the pointer to whether we have a sign of the C language. At the same time, the pointer is also the most difficult part in the C language. In addition to understanding the basic concepts in the study, it must be multi-programmed and debugged. As long as you do this, the pointer is not difficult to master.
The basic concept of the pointer is in the computer, and all the data is stored in the memory. Generally, one byte in the memory is called a memory cell. The number of memory cells occupied by different data types is not equal. If the integer amount is 2 units, the character quantity accounts for 1 unit, etc., in the second chapter Detailed introduction. In order to properly access these memory cells, the number must be made for each memory unit. The memory unit can be accurately found according to the number of a memory cell. The number of the memory cell is also called the address. Since the required memory unit can be found according to the number or address of the memory cell, this address is usually referred to as a pointer. The content of the memory cell and the content of the memory cell is two different concepts. You can use a popular example to explain the relationship between them. When we go to the bank to deposit, the bank staff will find our deposit slip according to our account. After finding it, it is found to write deposits on the deposit order, withdraw the amount. Here, the account is the pointer of the memory, and the number of deposits is the content of the memory. For a memory unit, the address of the unit is a pointer, where the data stored is the content of the unit. In the C language, a variable is allowed to store the pointer, which is called a pointer variable. Therefore, the value of a pointer variable is the address of a memory cell or a pointer called a memory unit. In the figure, character variable C is provided, its content is "K" (ASCII code is a decimal number 75), and C occupies the 011A unit (address hexadecimal representation). It is provided with a pointer variable P, which is 011A. This condition we call P pointing to variable C, or P is pointed to the variable C. Strictly speaking, a pointer is an address and is a constant. And a pointer variable can be given different pointer values, which is changed. However, the pointer variable is often referred to as a pointer. In order to avoid confusion, we agree that: "pointer" means the address, the constant, "pointer variable" means a variable of the value of the address. The purpose of defining a pointer is to access memory cells through a pointer. Since the value of the pointer variable is an address, then this address can be the address of the variable, but also the address of other data structures. What is the meaning of the first address stored in a pointer variable or a function? Because array or functions are continuously stored. The array or function is found by accessing the argument variables, and the array or function is found. In this way, any array, where the function can be expressed in a pointer variable, as long as the pointer variable gives an array or the first address of the function. In doing so, the concept of the program will be very clear, the program itself is also refined, efficient. In C language, a data type or data structure often occupies a set of continuous memory cells. With the concept of "address", it does not describe a data type or data structure, and "pointer" is actually an address, but it is the first address of a data structure, it is a "pointing" a data structure. And thus concept is more clear, indicating more clear. This is an important reason for introducing the concept of "pointer".