The pointer is inseparable from the address, referring to the pointer should think of the address, because in the C language, the value of the pointer variable is an address, through which it can point to the address of the memory location, you can access the memory location of the content through this pointer variable.
The method that defines a pointer variable is the same as the other variables:
int *a;
Char *b;
...
Here the pointer variable A is a pointer to the shaping, where the value of a is the address of the first byte of the four bytes of the shaping space pointed to, B is a pointer to the character type, and the value of B is the address of the character.
To initialize a pointer:
int a=123;
int *p=&a;
int *pi;
p=&a;
This defines the shaping variable A, which defines the pointer p, PI, and they all point to a, both of which are initialized so that they point to a.
Operation of the pointer:
The process of accessing the address it points to by a pointer is called an indirect access or a pointer dereference, and its operator is *. For example, the following definition
int a=12;
int b;
int *p;
p=&a;
B=*p;
Define the pointer p it points to the variable a, if you want to assign a value to B, you can use the pointer p to manipulate, the pointer p to dereference *p can get p point to the content of the address, you can assign the value of a to B.
Pointers and Arrays:
The value of the array name is a pointer constant, that is, the address of the first element of the array, when the pointer is dereferenced and an array of subscript access is equivalent, we can assume that the subscript access operator [] and the reference operator * can be swapped with each other.
int arr[5]={1,2,3,4,5};
The value of arr[0] is 1
The value of *arr is also 1, which is equivalent to * (arr+0)
How to feel the more write more feel the more useless!!!!
This article is from the "Aiali" blog, make sure to keep this source http://aliddd.blog.51cto.com/10780547/1711614
The most powerful of C language--pointers