Aspire's Library

A Place for Latest Exam wise Questions, Videos, Previous Year Papers,
Study Stuff for MCA Examinations - NIMCET

Previous Year Question (PYQs)



How will you free the memory allocated by the following program?
#include <stdio.h>

#define MAXROW 3
#define MAXCOL 4

int main()
{
    int **p, i, j;

    p = (int **)malloc(MAXROW * sizeof(int*));

    return 0;
}






Solution

Memory allocated using malloc() is released using free().


Here, memory is allocated to pointer p, so it should be freed as: free(p);



Online Test Series,
Information About Examination,
Syllabus, Notification
and More.

Click Here to
View More


Online Test Series,
Information About Examination,
Syllabus, Notification
and More.

Click Here to
View More

Ask Your Question or Put Your Review.

loading...