c - How to allocate memory to int (*a)[2]? -


how allocate memory integer type (*a)[2] ? comfortable doing **a, *a etc. etc., *a[2], looks different.

can out ? in advance.

same pointer type, have

int (*a)[2]; 

a pointer a arrays of 2 int, allocate

a = malloc(number_of_rows * sizeof *a); 

to block of number_of_rows * (2 * sizeof (int)) bytes.

you access with

a[i][j] 

with 0 <= < number_of_rows , 0 <= j < 2.


Comments

Popular posts from this blog

matlab - How to equate a structure array to structure array -

c# - Operator '==' incompatible with operand types 'Guid' and 'Guid' using DynamicExpression.ParseLambda<T, bool> -