In Java, we get a beautiful exception when attempting to access and array out of bounds, but in C that's not the case:
#include <stdio.h>
int main() {
int x[10] = {1,2,3}; // After the third index, I know that the rest are 0.
int i = 0;
while (i<99) { // Here I exceed the size of the array,
printf("%d",x[i]); // printing non-existent indexes.
i++;
}
return 0;
}
And the output is:
12300000001021473443840268687241986531780216078041842686812-12686816199941806157
0338438-2199933010019993299657804184019993359001214734438441990611-819265930944-
8192925345321-122881852697619690479012147344384268694020027537742147344384145346
587600214734438400102686884-819226869482003047601567625672026869562002753732-120
02706633004199040214734438402020893505321130682200320201752380100000243875924666
4687366080-21479789413447414207980
Process returned 1 (0x1) execution time : 0.719 s
Press any key to continue.
Technically, what exactly happened? It's not exactly an "int size overflow", right?