October 2004
Intermediate to advanced
336 pages
6h 27m
English
If you have split the code into sections with goals and identified the real meaning of each variable, and nothing has jumped out as being incorrect, you can proceed to choosing inputs and walking through the code. First, however, you can quickly scan the code for a few “gotchas” without getting into the nitty-gritty details.
Loop counters are often used to index into arrays. In languages that have zero-based arrays, notice if the check to exit a loop uses <= in the comparison, as opposed to <. Code such as the following
for (index = 0; index <= MAX_COUNT; index++) {
j = array[index];
}
might be correct, but the comparison index <= MAX_COUNT is suspicious. Normally, with a zero-based array, it should be ...
Read now
Unlock full access