I've got an unusual condition. Here's the snippet:
int i, j;
short ** s = (short **)malloc(128);
for(i = 0; i < 14; i++){
s[i] = (short *)malloc(128);
for(j = 0; j < 128; j++)
s[i][j] = 0;
}
printf("Value of s[%d][%d] = %d\n",2,40,s[2][40]);
s[1][108] = 99;
printf("Value of s[%d][%d] = %d\n",2,40,s[2][40]);
The output I get when I run this is:Value of s[2][40] = 0
Value of s[2][40] = 99
Eliminating the loops and writing short s[14][128] yields the correct output (Value of s[2][40] is 0 in both prints)
Why am I able to access s[2][40] with s[1][108]? I'm using gcc on Ubuntu 12.04.