-
What will be the output of the following C code?
#include <stdio.h>
int main()
{
int *((*ptr)())[20];
ptr();
printf("After ptr\n");
}
int *((*ptr)())[20]
{
int **s;
s = (int*)malloc(sizeof(int)* 20);
return s;
}
-
- After ptr
- Garbage vlaue
- Undefined behaviour
- Compilation Error
- None of these
Correct Option: D
Compilation Error
main.c: In function ‘main’:
main.c:4:17: error: ‘ptr’ declared as function returning an array
int *((*ptr)())[20];
^~~
main.c: At top level:
main.c:9:5: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
{