Home  >  Article  >  Backend Development  >  What does * mean in c language?

What does * mean in c language?

烟雨青岚
烟雨青岚Original
2020-07-06 09:47:2147665browse

* in C language means pointer. Pointers refer to memory addresses, and pointer variables are variables used to store memory addresses. Different types of pointer variables occupy the same storage unit length, while variables that store data occupy different lengths of storage space depending on the type of data. different.

What does * mean in c language?

* in C language means pointer.

Pointers are an important concept and feature in C language. They are also a difficult part of mastering C language. Pointers are memory addresses. Pointer variables are variables used to store memory addresses. Different types of pointer variables occupy the same storage unit length, while variables that store data occupy different lengths of storage space depending on the type of data. different.

After having a pointer, you can not only operate on the data itself, but also on the variable address where the data is stored.

Type description of pointer variable

The type description of pointer variable includes three contents:

(1) Pointer type description, that is, defining the variable It is a pointer variable;

(2) Pointer variable name;

(3) The data type of the variable pointed to by the variable value (pointer).

Its general form is: type specifier * variable name;

Among them, * indicates that this is a pointer variable, and the variable name is the defined pointer variable name. The type specifier indicates the data type of the variable pointed to by this pointer variable.

For example: int *p1; means p1 is a pointer variable, and its value is the address of an integer variable. In other words, p1 points to an integer variable. As for which integer variable p1 points to, it should be determined by the address assigned to p1.

Another example:

staic int *p2; /*p2 is a pointer variable pointing to a static integer variable*/

float *p3; /*p3 is a pointer to a float Pointer variable of point variable */

char *p4; /*p4 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, such as P3 can only point to Floating point variables cannot point to a floating point variable sometimes and point to a character variable sometimes.

Recommended tutorial: "C Language"

The above is the detailed content of What does * mean in c language?. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn