在函数中使用以下变量.
int i = 0;
int* ptr = &i;
Run Code Online (Sandbox Code Playgroud)
在函数中,内存布局可能类似于:
内存对应于i:
+---+---+---+---+
| 0 |
+---+---+---+---+
^
|
Address of i
Run Code Online (Sandbox Code Playgroud)
内存对应于ptr:
+---+---+---+---+
| address of i |
+---+---+---+---+
^
|
Address of ptr
Run Code Online (Sandbox Code Playgroud)
在上面的场景中,
*ptr == i == 0
ptr == address of i == address of memory location where the vale of i is stored
&ptr == address of ptr == address of memory location where the value of ptr is stored.
Run Code Online (Sandbox Code Playgroud)
希望有道理.