Which is more optimum using an multidimensional array like. int arr[100][100]; or pointer to pointer like int **arr; with molloc | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Which is more optimum using an multidimensional array like. int arr[100][100]; or pointer to pointer like int **arr; with molloc

With arr=(int**) malloc(100*sizeof(int*)); for(int i=0; i<100;i++) arr[i]=(int*)malloc(100*sizeof(int));

24th Jan 2021, 2:14 PM
Vaibhav
Vaibhav - avatar
1 Answer
+ 3
int arr[100][100]; is allocation in stack. int** arr = (int**)malloc( 100 * sizeof( int ) ); is allocation in heap. How can we compare these two memory allocation method? And what is actually meant by "more optimum"? in what way?
24th Jan 2021, 2:55 PM
Ipang