You are here:

C/Prob. Array Index

Advertisement


Question
Why Array index in C Language begins at 0[zero]?

Answer
This has something to do with the way pointers work.
Array name is a constant pointer pointing to the base address of the memory at which array starts. When you use array[i], the compiler calculates it as *(array + i). Since array is the address of the first element, the value of i will be 0 for accessing it. That's why array index starts at 0.

C

All Answers


Answers by Expert:


Ask Experts

Volunteer


Narendra

Expertise

I can answer questions in C related to programming, data structures, pointers and file manipulation. I use Solaris for doing C code and if you have questions related to C programming on Solaris, I will be able to help better.

Experience

6.5

Organizations belong to
Sun Microsystems

Awards and Honors
Brain Bench Certified Expert C programmer.
Advanced System Software Certified

©2012 About.com, a part of The New York Times Company. All rights reserved.