指针(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转载请标明出处.