In C language, & (address operator) is used to get the address of a variable, while (dereference operator) is used to get the value pointed to by the pointer. & returns a pointer and returns the data type pointed to by the pointer. & can be used for any variable, while * can be used only for pointer variables. They are used for pointer operations, dynamic memory allocation, and accessing the value pointed to by a pointer.
The meaning of & and * in C language
In C language, & and * are two very special characters. Important operator, used for pointer operations and reference variables.
& (address operator)
Example:
int num = 10; int *ptr = # printf("%p\n", ptr); // 输出 num 变量的地址
* (Dereference Operator)
Example: The difference between
int num = 10; int *ptr = # printf("%d\n", *ptr); // 输出 num 变量的值
& and *
Usage scenarios
The above is the detailed content of What do & and * mean in C language?. For more information, please follow other related articles on the PHP Chinese website!