This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

2 dimensional array



I am trying to malloc or calloc a 2 dimensional array and it is not calloc-ing correctly.  It zeros out the pointers to the rows (1D array), but callocing memory for the columns is not working.  

short ** idx = (short**)calloc(size,sizeof(short*));
for(i = 0; i < size; i++)
     idx[i] = (short*)calloc(size,sizeof(short));

Also, I am trying to access a different 2D array and am getting wrong results.  It is not accessing the correct indexes and returning the correct values.

What can I do to correct this?

Thanks,

sal