Home » C Programming » Pointers » Question
  1. 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;
    }
    1. After ptr
    2. Garbage vlaue
    3. Undefined behaviour
    4. Compilation Error
    5. 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
{



Your comments will be displayed only after manual approval.