+ 1

Change indexes

How can i index the starting of an array from 1 instead of zero c++

12th Jul 2020, 3:45 PM
Michel Ghaith
Michel Ghaith - avatar
1 Answer
+ 1
An array is basically a pointer, and indexing is simply taking the memory location of the head of the array and apply an offset. Thus, [arr + 0] is the fisrt element, [arr + 1] the second, and so on.
12th Jul 2020, 5:13 PM
Théophile
Théophile - avatar