Understood definition of C language pointer

Pointer Definition Format:
Type Name * pointer;
Example: int * p;


Pointer generally used to store the memory address, we can modify the contents of the memory address, in this way is called direct access.

Each variable and function have their corresponding memory address, as long as the variable with the function has not been released, there has been.

The pointer can be understood as a hotel house number, and the variable pointer can be understood as a hotel guest.


Destination pointer is used to save memory space.

For example, I want a int a [1024] array passed to the function B, if the function were a B array passed by value, will come in a copy of a copy, it will waste a lot of time and performance.


Imagine a, if the first address to a transfer function B, then the function would not copy B operation, direct use of a pointer to the array.
Also can be understood:
a traveler staying in a hotel is an A, B is a function of the hotel B, B also has a hotel named a passenger, I want to kill A traveler, so I want to get the passengers of the hotel A house number.

So in the C language, the arrays as parameters when passed to another function, the default delivery is an array of pointers.

example:

int a =5;
int *p = &a;
//&为取地址符,取a的地址

Guess you like

Origin blog.csdn.net/u013594490/article/details/93732377
Recommended