20200104-指针

  1. #include "stdafx.h"

  2. #include "iostream"

  3. #include "cstring"

  4. #include "string"

  5. using namespace std;

  6. int main()

  7. {

  8.   //第一组代码

  9.   int updates=6;

  10.   int *pt=&updates;

  11.   cout<<"pt= "<<pt<<endl;

  12.   cout<<"*pt= "<<*pt<<endl;

  13.   *pt+=1;

  14.   cout<<"加1后*p=t "<<*pt<<endl;

  15.   cout<<"加1后updates= "<<updates<<endl;

  16.   //第二组代码

  17.   int nights=1001;

  18.   int *pt1=new int;

  19.   cout<<"*pt1="<<*pt1<<endl;

  20.   *pt1=1001;

  21.   cout<<&nights<<endl;

  22.   cout<<pt1<<endl;

  23.  

  24.   cout<<sizeof(*pt1)<<endl;

  25.   double *pt2=new double;

  26.   *pt2=10.0;

  27.  

  28.   cout<<sizeof(*pt2)<<endl;

  29.   cout<<pt2<<endl;

  30. }

posted @ 2020-05-21 08:13  财盛  阅读(123)  评论(0编辑  收藏  举报