+1

Why Do We Have To Initialize When We Reserve Memory With Malloc?

https://stackoverflow.com/questions/8740195/how-do-we-allocate-a-2-d-array-using-one-malloc-statement I am trying to understand how to make 2d array with pointers. I found this link. I can't understand fully why do have to initialize each row to its first element. What I also understood from second comment on this link is that he is pointing to array[nrows] from data. After that array[i] take its position as array[nrows] but after this iteration array[i] takes its position as array[nrows+1]?it's not pssible

12/14/2017 7:31:56 AM

Yusuf

1 Answer

New Answer

+12

Perhaps you might have missed this from the 1st answer from your link: "You then need to go through and initialize the row pointers so that each row's pointer points at the first element for that particular row..."