【杂】指针,*,&

一个小程序解释指针变量的作用:

#include<iostream>
#include"cww.h"

void cloud(int *);

using namespace std;

int main(){
    int n = 1;
    int *p = &n;
    cloud(p);
    cout<<"&n = "<<(&n)<<",  n = "<<n<<endl;
    system("PAUSE");
    return 0;
}

void cloud(int *p)
{
    *p = 13;
     cout<<" p = "<<p<<", *p = "<<(*p)<<endl;
}

输出:

  p = 003FFEB0,  *p = 13
 &n = 003FFEB0,   n = 13  

 

posted @ 2016-05-09 00:47  Liez  阅读(157)  评论(0编辑  收藏  举报