Why does the indexing start with zero in 'C'?

前端 未结 16 2478
执念已碎
执念已碎 2020-11-22 16:22

Why does the indexing in an array start with zero in C and not with 1?

16条回答
  •  攒了一身酷
    2020-11-22 16:52

    Because it made the compiler and linker simpler (easier to write).

    Reference:

    "...Referencing memory by an address and an offset is represented directly in hardware on virtually all computer architectures, so this design detail in C makes compilation easier"

    and

    "...this makes for a simpler implementation..."

提交回复
热议问题