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
Bekam, siapa takut? - SAAT penyelenggaraan olimpiade di Rio tahun lalu, sempat viral pada media sosial pada beberapa atlet yang di bagian tubuhnya menampakkan lingkaran kemeraha...
1 day ago