c - Why no error is thrown in compilation or running -


this question has answer here:

int main() {     int a[2] = {1,2};     a[2] = 3;     printf("\n\n%d  %d  %d\n\n",a[0],a[1],a[2]);     return 0; } 

i output 1 2 3

why no error thrown @ run time or compile time?

have heard security problems caused buffer overruns? exist because c doesn't have automatic array bounds checking. it's programmer's responsibility ensure don't address outside array limit, compiler doesn't check it.


Comments

Popular posts from this blog

c# - Send Image in Json : 400 Bad request -

javascript - addthis share facebook and google+ url -

ios - Show keyboard with UITextField in the input accessory view -