[Tuxcpprogramming] Array begins at one
Mark Phillips
mark at austrics.com.au
Thu Jul 19 11:19:04 UTC 2001
Ray Hong wrote:
> Hi! there,
>
> Could anyone tell me how to devise an array which begins at
> one not at zero.
>
The easiest way is to have an array which begins at 0, but to ignore
the zeroth element. Ie, if you want an array from 1...8 of int, do:
int array[9];
which will give you an array from 0...8, and then you just ignore
array[0].
There are other ways but this is the easiest. Why do you want
the array to start at 1?
Cheers,
Mark.
More information about the tuxCPProgramming
mailing list