Output array address by using array pointer : array pointer « Array « C++ Tutorial






#include <assert.h>
#include <iostream>
#include <iomanip>

char array[10] = "012345678";

int main()
{
    for (int i = 0; i < 10; ++i) {
        std::cout << std::hex;
        std::cout << "&array[i]=0x" <<  reinterpret_cast<int>(&array[i]) <<
                     " (array+i)=0x" << reinterpret_cast<int>(array+i) <<
                     " array[i]=0x" <<  static_cast<int>(array[i]) << '\n',
        std::cout << std::dec;
    }
    return (0);
}
&array[i]=0x43d000 (array+i)=0x43d000 array[i]=0x30
&array[i]=0x43d001 (array+i)=0x43d001 array[i]=0x31
&array[i]=0x43d002 (array+i)=0x43d002 array[i]=0x32
&array[i]=0x43d003 (array+i)=0x43d003 array[i]=0x33
&array[i]=0x43d004 (array+i)=0x43d004 array[i]=0x34
&array[i]=0x43d005 (array+i)=0x43d005 array[i]=0x35
&array[i]=0x43d006 (array+i)=0x43d006 array[i]=0x36
&array[i]=0x43d007 (array+i)=0x43d007 array[i]=0x37
&array[i]=0x43d008 (array+i)=0x43d008 array[i]=0x38
&array[i]=0x43d009 (array+i)=0x43d009 array[i]=0x0








4.3.array pointer
4.3.1.Array pointer
4.3.2.Index a pointer as if it were an array
4.3.3.Use a 2-D array of pointers to create a dictionary
4.3.4.Output array address by using array pointer
4.3.5.passing array as a constant pointer
4.3.6.array accessed with array notation
4.3.7.array accessed with pointer notation
4.3.8.array accessed with pointer
4.3.9.an array of pointers to strings
4.3.10.Relationship between pointers and arrays