How do I free this array? Is this enough? Would it be enough to write only free(arr)
? Do I need to free **arr
? If yes, how can I do that?
Thanks in advance!
#include <stdio.h>
#include<stdlib.h>
#define N 5
int main(void)
{
int **arr = malloc(N*sizeof(int*));
for(int i=0;i<N;i++)
{
arr[i] = malloc(N*sizeof(int));
}
for(int i=0;i<N;i++)
free(arr[i]);
free(**arr);
return 0;
}