pointers are very important data types in C , so what is a pointer?
A pointer type is a variable used to hold the address of a variable, pointing to a variable.
General form of the pointer:* pointer variable name
int *p;
float *P1;
"*" is used to indicate that the variable is a pointer variable, and the preceding type identifier indicates the type of the variable being pointed to
Define an integer variable A and initialize it to 10
int a = 10;
Defines a pointer variable p, which can point to an int's address
int *p;
Assigns the address of variable A to the pointer variable p, so the pointer variable p points to the variable a
p = &a;//& can get the address of a variable in memory
Error instance:
int *g;
g = 20;
The value of a pointer variable is generally not directly assigned to an integer, but instead is assigned by a variable address, as follows:
*p = 20;
printf ("a=%d\n", a);
Void *p3;//This is called an untyped pointer, meaning this is just a pointer variable that does not point to any specific data type, but can be converted to a different type pointer by a forced conversion, or you can use (void *) to convert other type pointers to void type pointers
Null pointer: The value of the pointer is null
C-language pointers