Sail E0 Webinar
Question


Point out the correct statement which correctly free the memory pointed to by 's' and 'p' in the following program?


#include<stdio.h>
#include<stdlib.h>
iint main()
{
struct ex
{
int i;
float j;
char *s
};
struct ex *p;
p = (struct ex *)malloc(sizeof(struct ex));
p->s = (char*)malloc(20);
return 0;
}
Options:
A .  free(p); , free(p->s);
B .  free(p->s); , free(p);
C .  free(p->s);
D .  free(p);
Answer: Option B



Submit Your Solution Below and Earn Points !
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers