X hits on this document

140 views

0 shares

0 downloads

0 comments

13 / 63

Copyright ©2004 Pearson Addison-Wesley. All rights reserved.

8-13

Array Subscripts

We use subscripts/indices to differentiate between the individual array elements

We can use any expression of type int as an array subscript.

However, to create a valid reference, the value of this subscript must lie between 0 and one less than the array size.

It is essential that we understand the distinction between an array subscript value and an array element value.

int x[2]; int y = 1; x[y] = 5;

      The subscript is y (which is 1 in this case), and the array     element value is 5

C compiler does not provide any array bound checking. As a programmer it is your job to make sure that every reference is valid (falls within the boundary of the array).

Document info
Document views140
Page views140
Page last viewedMon Dec 05 21:16:04 UTC 2016
Pages63
Paragraphs754
Words4119

Comments