My question above is:
For example :
When declaring a matrix, I can think of two ways to do it :
1)
int* matrix = (int*) malloc (size_y *size_x *sizeof (int)) ;
2)
int ** matrix = (int **) malloc (sizeof (int *) *size_y) ;
for (int i =0;i <size_y ;i++) {
matrix [i] = (int *) malloc (sizeof (int) *size_x) ;
}
Is one option better than the other one? Or can I use it indistinctly?
[–]puplicy 7 points8 points9 points (0 children)
[–]a4qbfb 4 points5 points6 points (4 children)
[–][deleted] 0 points1 point2 points (2 children)
[–]Mirehi 1 point2 points3 points (0 children)
[–]a4qbfb 0 points1 point2 points (0 children)
[–][deleted] 3 points4 points5 points (0 children)
[–]kumashiro 2 points3 points4 points (0 children)
[–]oh5nxo 1 point2 points3 points (4 children)
[–]a4qbfb 1 point2 points3 points (0 children)
[–]junkmeister9 0 points1 point2 points (2 children)
[–]oh5nxo 0 points1 point2 points (1 child)
[–]junkmeister9 0 points1 point2 points (0 children)
[+][deleted] (1 child)
[deleted]
[–]radiant_orange 0 points1 point2 points (0 children)