How I am able to put more elements in an array whose size is fixed?

  arrays, c++, crash

on my computer when I am declaring an array in C++, say for example this

int mynum[3];
mynum[0]=1;
mynum[1]=2;
mynum[2]=3;

mynum is an array which can hold 3 elements,
now when I add this line

mynum[3]=4;

it crashes on Windows and on Ubuntu terminal ( stack smashing detected unknown terminated core dumped )
but when I use,

mynum[4]=56;
mynum[5]=34;
mynum[6]=23;

it does not gives any error ( when I use above three line in place of mynum[3] )
why is this happening ?

Source: Windows Questions C++

LEAVE A COMMENT