Q:
How would you free the memory allocated by the following program?
#include "alloc.h"
#define MAXROW 3
#define MAXCOL 4
main()
{
int **p, i;
p = (int **) malloc (MAXROW * sizeof (int *));
for ( i = 0; i < MAXROW ; i++)
p[i] = (int *) malloc (MAXCOL * sizeof (int ));
}
Answer
for ( i=0; i < MAXROW ; i++)
free (p[i]);
free (p);
View answer
Workspace
Report Error
Discuss