-
What will be the output of the following C code?
#include <stdio.h>
int *fun();
int main()
{
int *ptr = fun();
printf("%d\n", *ptr);
}
int *fun()
{
int *p = (int*)malloc(sizeof(int));
*p = 11;
return p;
}
-
- Compilation Error
- 11
- Undefined behaviour
- Segmentation fault/runtime crash since pointer to local variable is returned
- None of these
Correct Option: B
11