The output of the application (bottom) is as follows:
Element index number: 0 Element contents: 22
Element index number: 1 Element contents: 22
Element index number: 2 Element contents: 22
Element index number: 3 Element contents: 22
Element index number: 4 Element contents: 22
Element index number: 22 Element contents: 134513712
Why are index elements labeled 5 - 21 missed out? I understand this code could segfault do to the bounds of the array being overflowed, it is designed to do that, I'm not interested in why this code is bad, just why certain indexes are skipped.
#include <stdio.h>
int main(){
int array[5];
int i;
for(i=0; i<10; ++i){
array[i] = 22;
printf("Element index number: %d Element contents: %d\n", i, array[i]);
}
return 0;
}