Array indexing starting at a number not 0

后端 未结 13 2361
Happy的楠姐
Happy的楠姐 2021-02-20 04:02

Is it possible to start an array at an index not zero...I.E. you have an array a[35], of 35 elements, now I want to index at say starting 100, so the numbers would be a[100], a[

13条回答
  •  深忆病人
    2021-02-20 04:37

    strictly speaking, this solution does not loet you define an array starting at an index different from 0, but you may declare your memory this way:

    typedef union
    {
        unsigned char all[15000];
        struct
        {
            unsigned char sram[10000];
            unsigned char bram[5000];
        };
    } memory;
    

    this does convey the intent that the memory is contiguous, and that it is split in 2 parts. note that you should beware of the alignment of bram and sram, a #pragma pack(1) may be necessary.

提交回复
热议问题