https://www.runoob.com/cplusplus/cpp-pointer-operators.html
- *是一元运算符,返回操作数所指定地址的变量的值。(取地址的值)
- & 是一元运算符,返回操作数的内存地址。(取地址)
#include <iostream>
using namespace std;
int main ()
{
int var;
int *ptr;
int val;
var = 3000;
// 获取 var 的地址
ptr = &var;
// 获取 ptr 的值
val = *ptr;
cout << "Value of var :" << var << endl;
cout << "Value of ptr :" << ptr << endl;
cout << "Value of val :" << val << endl;
return 0;
}
Value of var :3000
Value of ptr :0xbff64494
Value of val :3000