X hits on this document

138 views

0 shares

0 downloads

0 comments

16 / 63

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

8-16

Access (2)

int x[5];  // declare an integer array of size 5

int i = 2;

x[0] = 20; // valid

x[2.3] = 5;  // Invalid, index is not int

x[6] = 10; // valid, but dangerous

x[2*i – 3] = 3; // valid, assign 3 to x[1]

x[i++];   // access x[2] and then assign 3 to i

x[(int) x[1]]; // access x[3]   

Referencing to an array element outside of the created bounds is possible but rather not recommended.

Document info
Document views138
Page views138
Page last viewedMon Dec 05 09:19:56 UTC 2016
Pages63
Paragraphs754
Words4119

Comments