/*
**test17.cpp : Defines the entry point for the console application.
**系统winXP SP3 32位.
**关于指针
*/
#include "stdafx.h"
#include "stdio.h"
#include "iostream.h"
int main(int argc, char* argv[])
{
int iNum = 0;
char cNum = 'a';
float fNum = iNum;
double dNum = fNum;
bool bNum = true;
int* piNum = &iNum;
int** ppiNum = &piNum;
cout<<"address iNum is: "<<&iNum<<endl; //0x0012FF7C
printf("address cNum is: 0x%p\n",cNum); //0x00000061
cout<<"address fNum is: "<<&fNum<<endl; //0x0012FF74
cout<<"address dNum is: "<<&dNum<<endl; //0x0012FF6C
cout<<"address bNum is: "<<&bNum<<endl; //0x0012FF68
cout<<"value piNum is: "<<piNum<<endl; //0x0012FF7C
cout<<"address piNum is: "<<&piNum<<endl; //0x0012FF64
cout<<"value ppiNum is: "<<ppiNum<<endl; //0x0012FF64
cout<<"address ppiNum is: "<<&ppiNum<<endl; //0x0012FF60
return 0;
}
Tips1:上例我们可以看出指针的值是32bit的正整数,指针piNum的值就是iNum的地址0x0012FF7C,同理ppiNum的值就是指针piNum的地址0x0012FF64。