2D array dynamic memory allocation crashes [duplicate]
问题 This question already has answers here : Closed 7 years ago . Possible Duplicate: How do I correctly set up, access, and free a multidimensional array in C? I am trying to dynamically allocate memory for a 2D array using calloc. The columns are fixed as 2 so its only the rows that are dynamic. Here is what I have been trying : unsigned int **pts, rows; int main() { //some code pts = (unsigned int **)calloc(2*rows, sizeof (unsigned int **)); } //The code to access the array : for(k=1;k<=i;k++)