Array indexing starting at a number not 0

后端 未结 13 2290
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:41

    No — as in you can't modify the lower bound in declaration like VB6.

    Yes — as in you can do tricks like

    int a[35];
    int* actual_a = a-100;
    printf("%d", actual_a[101]);
    ...
    

    because x[a] is equivalent to *(x+a). This is highly unrecommended.

提交回复
热议问题