ch8_3.cpp
资源名称:c.rar [点击查看]
上传用户:puke2000
上传日期:2022-07-25
资源大小:912k
文件大小:0k
源码类别:

C#编程

开发平台:

Visual C++

  1. //*********************
  2. //**    ch8_3.cpp    **
  3. //*********************
  4. #include <iostream.h>
  5. void main()
  6. {
  7.   float f=34.5;
  8.   float* fPtr=&f;         //浮点指针
  9.   int* iPtr=(int*)&f;     //warning: 将浮点变量的地址赋给整型指针
  10.   cout <<f <<endl
  11.        <<"iPtr:" << iPtr <<"=>" <<*iPtr <<endl
  12.        <<"fPtr:" << fPtr <<"=>" <<*fPtr <<endl <<endl;
  13.   *iPtr=*fPtr;            //隐式数据转换
  14.   cout <<f <<endl
  15.        <<*iPtr <<endl
  16.        <<*fPtr <<endl;
  17.   cin.get();
  18. }