正在加载图片...
上海交通大学交大密西根 ·联合学院一 81 UM-SJTU Joint Institute University of Michigan Shanghal Jiao Tong University Indexing Problem Any integer variable i can be used as an array index.C comnilars do not check to see thet the indey valis V #define MAX EXAMS 500 main() [ W int i; int scores [MAX EXAMS]; al Square brackets and an index are ti scores[1]99; i=·· used to set or access the value of an scores[i]100; array element. if (scores[i]high) It's up to you to be sure the index high scores[i];is valid.Indexing Problem Indexing Problem • Any integer variable i can be used as an array index. C compilers do not check to see that the index value is valid for the given array. If i here was 523, the statement scores[i] = 100; would store 100 somewhere, but it wouldn’t be in the array! Doubtless an error would occur, but maybe not till later
<<向上翻页向下翻页>>
©2008-现在 cucdc.com 高等教育资讯网 版权所有