#include <iostream>
#include<stdio.h>
using namespace std;
int main()
{
int a; //定義整形變數a
int b = 10; //定義整形變數b並初始化爲10
a = 11; //a賦值爲11
cout<<"a = "<<a<<endl;
printf("b = %d\n", b);
int *p = &a; // 將變數a的地址賦給整型指針變數p,p中存放的是地址, int * 表示整型變數指針
cout<<"*p = "<<*p<<endl; //*p表示取p存的地址指向的變數的值,即a的值
cout<<"p = "<<p<<endl; //p中是變數a的地址值
printf("p = %p\n", p); // C語言中列印變數地址用%p
*p = *p+1;
cout<<"a = "<<a<<endl;
p = NULL;
cout<<"p = "<<p<<endl;
return 0;
}
注意: