Regarding Out of bound array element acess

view full story

http://www.linuxquestions.org – Hi, as i understand c doesnot perform bound checking , and any acess of previous index will just get the prev indexed mem contents and same for beyond index. main() { int y = 98; int a[5]={11,12,13,14,15}; int z = 541; printf("a[0]=%d a[4]=%d\n",a[0], a[4]); printf("a[-1]=%d\n",a[-1]); printf("a[5]=%d\n",a[5]); return 0; } [santosh@localhost test]$ ./a.out a[0]=11 a[4]=15 a[-1]=134518428 .. why it is not 98? as it refrers to prev mem location a[5]=98 ... and i 'm confused how its 98 but should be 541. If the same set of local variables is made global s it works , so is theat difference because of stack ? Plz provide clarification, thanks in advance. (HowTos)