• 数组和指针


    数组名同时也是该数组首元素的地址。

    #define SIZE 4

    short dates [SIZE];

        dates[0] = 1;

        dates[1] = 2;

        dates[2] = 3;

        dates[3] = 4;

        

        short *pti;

        

        double bills[SIZE];

        bills[0] = 1.1;

        bills[1] = 2.2;

        bills[2] = 3.3;

        bills[3] = 4.4;

        double *ptf;

        

        short index;

        

        pti = dates;

        ptf = bills;

        

        printf("%23s %10s\n","short","double");

        for (index = 0; index<SIZE; index++)

        {

            printf("pointers +%d: value = %d ,address = %10p value = %.1f,address = %10p\n",index,*(pti+index),pti+index,*(ptf+index),ptf+index);

        }

        return0;

                             short                                                        double

    pointers +0: value = 1 ,address = 0x7fff5fbff830 value = 1.1,address = 0x7fff5fbff800

    pointers +1: value = 2 ,address = 0x7fff5fbff832 value = 2.2,address = 0x7fff5fbff808

    pointers +2: value = 3 ,address = 0x7fff5fbff834 value = 3.3,address = 0x7fff5fbff810

    pointers +3: value = 4 ,address = 0x7fff5fbff836 value = 4.4,address = 0x7fff5fbff818

     

    *(dates+2) == dates[2]          // 值相同

    dates +2 == &dates[2]    // 地址相同

     

    *优先级  大于 +

  • 相关阅读:
    CSS3实现翻转菜单效果
    C语言根据日期取其位于一年中的第几天
    实习第一周小记------生活不易
    [置顶] iOS开发规范
    理解 Neutorn LBaaS
    FWaaS 实践: 允许 ssh
    实践 Neutron FWaaS
    理解 Neutron FWaaS
    应用新安全组
    Neutron 默认安全组规则
  • 原文地址:https://www.cnblogs.com/sell/p/2835823.html
Copyright © 2020-2023  润新知