Quantcast
Channel: Active questions tagged gcc - Stack Overflow
Viewing all articles
Browse latest Browse all 22240

Are arrays treated as static data structures by gcc compiler or as dynamic? [duplicate]

$
0
0

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?


Viewing all articles
Browse latest Browse all 22240

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>