I thought arrays were considered static data structures.
Then we executed this:
#include <stdio.h>#include <stdlib.h>int main(){ int a[5] = {10,20,30,40,50}; a[5] = 100; a[6] = 200; printf("Out of bounds %d, %d", a[5], a[6]); return 0;}
This returns Out of bounds 100 200
and ends normally. WHY?
Why is 200 declared and returned normally if a[5]
is static?
Everything is leading me to the conclusion that gcc treats arrays as dynamic data structures.
Am I right? What is going on?