join CSDN It's for the record , I hope there are more deficiencies to correct .

<>1,char Pointer

Character pointer
char * p = "helloworld" ; Above writing “helloworld” Stored in constant area , Can be accessed , Cannot be modified ;( Read only data )
<>2, Multistage pointer
int a = 100 ; int * p = &a; // Primary pointer ,P point a Address of int **p1 = &p; // Secondary pointer ,p1 Pointer p Address of int
***p2 = &p1; // Tertiary pointer , p2 Pointer to secondary p1

Operation results :

<>3, Disassembly method of universal pointer :

Any pointer, no matter how complex , When disassembling, it is divided into two parts
char * p1; // Part I pointer variable name *p1 , The second part is the type of pointer pointed to by the pointer char char ** p2; // Part I *p2 , Part II
char * char (*p3)[3]; // Part I *p3, Part II char [3], Pointer to array , Array pointer char (*p4)(int ,
float); // Part I *p4, char(int , float),,,
be careful :
Above p1,p2,p3,p4 It's all a pointer. There's no difference in essence .
The only difference between the above pointers is that they point to different data types .

<>4,void Pointer

concept : It can be used when the pointer is not clear void Pointer ( Universal type pointer )
be careful :

* void Type pointers cannot be used directly to index targets , It must be cast and indexed again , To get the correct target data .
* void Type pointer cannot be added or subtracted directly .
void Three functions of keyword modification :

* Modifier pointer , Indicates that the type pointed to by the pointer is unknown .
* Modifier parameter list , Indicates that the function does not accept any parameters .
* Decorated return value type , Indicates that the function will not have any return value . void function(void);
The following code knowledge is understood as an experiment void Use of type pointer , Don't use it in actual development
// malloc Apply to the system for a piece of memory with a size of 4 byte , And let p To point to the memory void * p = malloc (4); *(int *)p =
25536 ; // Cast type to int * printf("%d\n" , *(int *)p); // Using the correct parsing method to parse the memory can get the correct value
printf("%d\n" , *(char *)p); // Using the wrong parsing method to parse the memory can get the wrong value
<>5,const Type pointer

There are two forms of decorating pointers :
1. Constant pointer
const The pointer itself is decorated , express P Cannot be modified , It can only point to the original content .
However, you can use this pointer to modify the memory content it points to .
// Constant pointer char * const p = "hello"; printf("%s\n", p); p = "world";
// error ,p Is a constant pointer , It is not possible to modify its pointing after initialization printf("%s\n", p); #include <stdio.h> int main(int
argc, char const *argv[]) { int n = 200; int m = 300; int *const p = &n; //p =
&m Wrong , Cannot refer to other addresses *p = 400; // You can modify the memory content it points to by changing the pointer printf("%d\n", *p); return 0; }
2. Constant target pointer
More common , Used to restrict the read and write permissions of the pointer , This pointer cannot be used to modify the contents of the memory it points to , But you can change his direction .
int a = 100; int b = 998; const int * p = &a; printf("%d\n" , *p); p = &b;
// The constant target pointer can modify its direction, but it cannot modify the contents of memory through it // *p = 200; // error ,p Is a constant target pointer , The pointer cannot be used to modify the content it points to
printf("%d\n" , *p);

Technology