how to make dynamic array with known number of column element
for example for a 3d coordinate.
suppose i need to make 2d dynamic array for a 3d coordinate, because the element of 3d coordinate is x, y, z so the number column is 3.
let's say i need to have
and that number is suppose unknown until we read the file, lets say ptscount.
one simple way to allocate the dynamic 2d array is as follow.
double (*point) = (double (*))malloc(sizeof(double) * ptscount*3);
- double (*point): double variable of "point" that has 3 array element, this will make point[ptscount]
- (double (*)): casting to double of pointer that has 3 array element
- malloc(sizeof(double) * ptscount*3): memory allocation for (the size of double variable) times(×) (ptscount (number or row of the array) with 3 column)
after using it you have to free the memory
Review sepatu trail run Asics gel sonoma 2 - LAMA sudah tak menyentuh blog ini. Banyak terlihat sawang di sudut-sudut ruangan blog yang perlu dibersihkan dengan sapu ijuk bergagang panjang. Berhubung ...
2 months ago