Fixed an "array index out of bounds violation" in the examples (regarding issue ).

This commit is contained in:
Fabian Zahn
2018-10-27 11:24:29 +02:00
parent 7d2bf62b7e
commit e84cb29acc

@ -11,7 +11,7 @@ int NumbersToFind[9] = { 0, 34, 55, 66, 32, 11, 1, 77, 888 }; /* some obnoxious
int FindFunction_WhichIsBroken(int NumberToFind) int FindFunction_WhichIsBroken(int NumberToFind)
{ {
int i = 0; int i = 0;
while (i <= 8) /* Notice I should have been in braces */ while (i < 8) /* Notice I should have been in braces */
i++; i++;
if (NumbersToFind[i] == NumberToFind) /* Yikes! I'm getting run after the loop finishes instead of during it! */ if (NumbersToFind[i] == NumberToFind) /* Yikes! I'm getting run after the loop finishes instead of during it! */
return i; return i;