下载此文档

指针(pointer)――CC精髓.doc


文档分类:IT计算机 | 页数:约9页 举报非法文档有奖
1/9
下载提示
  • 1.该资料是网友上传的,本站提供全文预览,预览什么样,下载就什么样。
  • 2.下载该文档所得收入归上传者、原创者。
  • 3.下载的文档,不会出现我们的网址水印。
1/9 下载此文档
文档列表 文档介绍
指针(pointer)――CC精髓..doc指针(pointer)――CC的精华.
指针(pointer)――CC的精华.
指针(pointer)――CC的精华.
指针 (pointer ——C/C++ 的精华!你不得不学好它!
指针 (pointer1, 3, 5, 7, 9}; ( arr 为常量指针)。此处字符数组名是一个指向该数组的常
量指针,它不可以从头赋值。
[ 例 ] 两种指针方式及其地点和字符串内容
str_ptr_& #include <> #include <> void main(
{
指针(pointer)――CC的精华.
指针(pointer)――CC的精华.
指针(pointer)――CC的精华.
char *nm = "Nice"; char name[ ] = "OK";
cout<<"Addresses of the pointers 'nm' and 'name' themselves:"<<endl; cout<<"'nm' is at "<<&nm<<", 'name' is at "<<&name<<endl;
指针(pointer)――CC的精华.
指针(pointer)――CC的精华.
指针(pointer)――CC的精华.
cout< setiosflags ( ios ::uppercase<<"'nm' points to 0x"<<( int nm;
cout<<", 'name' points to 0x"<<(intname<<endl;
cout<<"Character strings are '"<
cout< endl ;
}
/* Results:
Addresses of the pointers 'nm' and 'name' themselves:
'nm' is at 0x0065FDF4 (栈区) , 'name' is at 0x0065FDF0 (栈区)
'nm' points to 0x42608C (数据区) , 'name' points to 0x65FDF0 (栈区)
Character strings are 'Nice' and 'OK' respectively.
*/
说明:我在编程时的数据与此相差很大,读者需要自行地将上述代码运转一下 ...
程序中 cout<<(intname 用于读取指针内容即指针所指向的地点(字符串地点);而
cout< 则用于读取该指针所指向的字符串内容。
指向指针的指针
比如:
int i=5;
int *ptr = &i;
int **pp = &ptr;
即:
指向指针 ptr 的指针 整型变量 i 的指针 整型变量
指针(pointer)――CC的精华.
指针(pointer)――CC的精华.
指针(pointer)――CC的精华.
pp
指针(poin

指针(pointer)――CC精髓 来自淘豆网m.daumloan.com转载请标明出处.

相关文档 更多>>
非法内容举报中心
文档信息
  • 页数9
  • 收藏数0 收藏
  • 顶次数0
  • 上传人书生教育
  • 文件大小163 KB
  • 时间2022-01-23