Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - How to assign values ??to pointers in C language
How to assign values ??to pointers in C language

1. The pointer of a variable is the address of the variable. The variable that stores the address of the variable is a pointer variable. That is, in C language, a variable is allowed to store a pointer. This variable is called a pointer variable. Therefore, the value of a pointer variable is the address of a variable or a pointer to a variable.

2. In order to express the relationship between the pointer variable and the variable it points to, the "*" symbol is used to represent "pointing" in the program.

3. Define pointer variables. The definition of pointer variables includes three contents: pointer type specification, that is, defining the variable as a pointer variable and the basic form of the pointer variable name * variable name.

4. int i, j; means i, j is a pointer variable, and its value is the address of an integer variable. In other words, i and j point to an integer variable. As for which integer variable i and j point to, it should be determined by the address assigned to i and j.

5. int *s is a pointer variable pointing to an integer variable, float *d is a pointer variable pointing to a floating-point variable, and char *g; is a pointer variable pointing to a character variable. It should be noted that a pointer variable can only point to variables of the same type. For example, s can only point to a floating-point variable, and cannot point to a floating-point variable sometimes and a character variable sometimes.

6. Reference of pointer variables. Pointer variables are the same as ordinary variables. They must not only be defined before use, but also must be assigned a specific value. Unassigned pointer variables cannot be used, otherwise it will cause system chaos or even crash.