• pointer of 2d array and address


    1.int a;

    (&a) can be used just like a pointer, with no doubt.

    2.int a;

    cout<<(&a)<<endl;

    ---------

    Programme Run first,output:       0028FDF0;

    Programme Run Second,output:    003FFED0;

    This means that RAM allocates different storage address.

    ------------------

    output:  003FFE9C

                 003FFEA0

    This indicates that size of one int cost 4 bytes. 

    1 byte consists 8 bits.

    4.

    int arr[5]={1,2,3,4,5};
    cout<<arr<<endl;
    cout<<arr+1<<endl;//+1 not +1byte address, step +1 is +1 int_size, so +1 is overloading.
    int* brr=arr+1;
    cout<<brr[3]<<endl;

    ------------------

    output:  003FFE9C

                 003FFEA0

    This indicates that size of one int cost 4 bytes. 

    1 byte consists 8 bits.

    +1 not +1byte address, step +1 is +1 int_size, so +1 is overloading.

    5.

    int dd[3][2]={1,2,3,4,5,6};
    cout<<"&dd="<<&dd<<endl;
    cout<<"(&dd)+1="<<(&dd)+1<<endl;

    -----------------------------------

    &dd=001FFD80;

    (&dd)+1=001FFD98 // 24 bytes for one step.

    6.

    int dd[3][2]={1,2,3,4,5,6};
    int ddd[3][2]={7,8,9,10,11,12};
    cout<<"&dd="<<&dd<<endl;
    cout<<"(&dd)+1="<<(&dd)+1<<endl;

    cout<<"dd="<<dd<<endl;
    cout<<"dd+1="<<dd+1<<endl;

    --------------------------------

    3
    2
    1
    0038F8A0
    0038F894
    0038F888
    0038F86C
    0038F870
    5
    ---------------------
    &dd=0038F840
    (&dd)+1=0038F858 //
    dd=0038F840     // the same as above
    dd+1=0038F848 // 8bytes jump, which is 2ints jump
    请按任意键继续. . .

    --------------------------------------------

    &dd=0038F840 and  dd=0038F840   IS REALLY PUZZLING.

     =====================

    Conclusion: 

    1. Address has on address;

    2. Address has a hierachy;

    Hierachy means that step size of different address plus jumps different size.

    3. Starting Address usually coincides.

  • 相关阅读:
    版本控制 version control
    URL URI
    能用上的收藏
    函数式语言简介(functional language)
    h5触摸事件-判断上下滑动
    地理定位
    web存储
    jquerymobile tap事件被触发两次
    关于button的onclientclick事件和onclick事件
    .net 后台给html控件赋值
  • 原文地址:https://www.cnblogs.com/stevenxiu/p/5756188.html
Copyright © 2020-2023  润新知