Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - What are pointers and pointer variables?
What are pointers and pointer variables?
1, pointer is an important concept and its characteristics in C language, and it is also a difficult part to master in C language. Pointers are also memory addresses. Pointer variables are variables used to store memory addresses. Different types of pointer variables occupy the same length of storage units, while variables that store data occupy different lengths of storage space because of different data types.

Using pointers, you can not only manipulate the data itself, but also manipulate the variable address where the data is stored. ?

2. Pointer variables refer to variables that store addresses. Measurement reform of specific nature caused by address change.

Extended data:

Pointer variable definition:

1. Define the general form of pointer variable as follows:

Type name * pointer variable name 1, * pointer variable name 2, ... * pointer variable name n;

2. Null pointer

A null pointer is a special pointer with a value of 0. In C language, the symbol constant null (defined in stdio.h) is used to represent this null value, and it is guaranteed that this value will not be the address of any variable. Null pointers are legal to assign values to any pointer type. A pointer variable with an empty pointer value means that it is not pointing to anything meaningful at present.

3. Null pointer

A pointer of type (void *) is called a universal pointer, which can point to any variable. C language allows direct assignment of the address of any variable as a pointer to a universal pointer.

However, it should be noted that void* cannot point to variables modified by const, such as const int test void * PTV PTV = & test; The third sentence is illegal, only stating that ptv is const void * ptv, and the third sentence above PTV = &;; The test is legal.

When you need to use the data pointed by the universal pointer to participate in the operation, you need to write a type cast. For example, the data in the space pointed by the general pointer ptv is integer data, and p is an integer pointer, which is converted by this formula: p = (int *) PTV;

Baidu Encyclopedia-Pointer Variable

Baidu encyclopedia-pointer