ch8_17.cpp
资源名称:C.zip [点击查看]
上传用户:gzy2011
上传日期:2021-02-09
资源大小:20k
文件大小:0k
源码类别:

压缩解压

开发平台:

Visual C++

  1. //file ch8_17.cpp
  2. #include"iostream.h"
  3. void main(void)
  4. {
  5.  char buffer[10]="ABC";
  6.  char* pc;
  7.  pc="hello";
  8.  cout<<pc<<endl; //输出字符指针就是输出字符串:"hello",而非地址,除非如下:
  9.  cout<<hex<<(int)pc<<endl;//输出地址
  10.  pc++;           //pc指向'e'
  11.  cout<<pc<<endl;  //"ello"
  12.  cout<<*pc<<endl; //'e'
  13.  
  14.  pc=buffer; //pc指向"ABC"
  15.  cout<<pc<<endl; //"ABC"
  16. }