Array indexing starting at a number not 0

后端 未结 13 2281
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:42

    Pointers and arrays are very similar in C, so you could easilly do something like

    element SRAM_MEM[10000];
    element BRAM_MEM[5000];
    
    element* SRAM = SRAM_MEM;
    element* BRAM = BRAM_MEM-10000;
    
    BRAM[10001] = 0; // sets the first element of BRAM_MEM
    

提交回复
热议问题