C language pointer, C language pointer
Pointers are very important data types in C language. What are pointers?
The pointer type is a variable used to store the variable address, pointing to a variable.
Common pointer format: * pointer variable name
Int * p;
Float * p1;
"*" Is used to indicate that this variable is a pointer variable. The previous type identifier indicates the type pointing to the variable.
// Define an integer variable a and initialize it to 10
Int a = 10;
// Define a pointer Variable p that can point to the int address
Int * p;
// Assign the address of variable a to the pointer Variable p, so the pointer Variable p points to variable
P = & a; // you can obtain the address of a variable in the memory.
Error instance:
Int * g;
G = 20;
Generally, the value of a pointer variable cannot be directly assigned an integer, but is assigned by the variable address, as shown below:
* P = 20;
Printf ("a = % d \ n", );
Void * p3; // This is called a non-type pointer, which means this is only a pointer variable and does not point to any specific data type, however, you can convert void * to another type pointer by force conversion, or convert other types of pointer to void type pointer by using (void *).
NULL Pointer: the pointer value is NULL.