What is the output of this program?
#include<stdio.h>
#include<stdlib.h>
int main()
{
int *ptr1;
while(1){
ptr1 = malloc(1024*1024);
if(ptr1 == 0)
break;
sleep(1);
printf("Example\n");
free(ptr1);
}
return 0;
}
#include<stdio.h>
#include<stdlib.h>
int main()
{
int *ptr1;
while(1){
ptr1 = malloc(1024*1024);
if(ptr1 == 0)
break;
sleep(1);
printf("Example\n");
free(ptr1);
}
return 0;
}
A. it will print "Example" until the process has been stopped by any signal
B. it will print nothing
C. segmentation fault
D. none of the mentioned
Answer: Option A
Join The Discussion