c - Why no error is thrown in compilation or running -
this question has answer here:
- array index out of bound in c 9 answers
- why out of bound array accessible in c? [duplicate] 3 answers
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
Post a Comment