指针|Pointer
a pointer is a variable that contains the address of a variable.
指针是一个变量,包含一个变量的地址的变量。
在正式学习指针之前,需要先理解指针与地址的关系,see 指针与地址的物理关系
& 取地址运算符
unary operator &
gives the address of an object, so the statement
p = &c;
assigns the address of c
to the variable p
, and p
is said to point to c
.
The &
operator only applies to objects in memory: variables and array elements.
ps.如果不能理解,可以看一下对赋值符号的理解,再回来
* 间接或解引用运算符
The unary operator *
is the indirection or dereferencing operator; when applied to a pointer, it accesses the object the pointer point to.
declaration of pointer p
,指针的声明
int *p; /* ip is a pointer to int */
指针与数组
指针与数组是密切相关的,因此讨论指针必须要讨论C指针与数组的关系