How to allocate memory to int (*a)[2]?
问题 How do I allocate memory to integer type (*a)[2] ? I am comfortable doing it with **a, *a etc. etc., also *a[2], but this looks different. Can somebody help out ? Thanks in advance. 回答1: Same as for any pointer type, say you have int (*a)[2]; a pointer a to arrays of 2 int , then you allocate a = malloc(number_of_rows * sizeof *a); to get a block of number_of_rows * (2 * sizeof (int)) bytes. You then access that with a[i][j] with 0 <= i < number_of_rows and 0 <= j < 2 . 来源: https:/