Home » C Programming » Structures » Question
  1. What will be the output of the following C code?
    #include <stdio.h>
    struct point1
    {
    int x[2];
    };
    struct point2
    {
    int *x;
    };
    int main()
    {
    struct point1 p1 = {11, 22};
    struct point2 *ptr1 = (struct q*)&p1;
    ptr1->x = (struct q*)&p1.x;
    printf("%d\n", ptr1->x[0]);
    }
    1. Compilation Error
    2. Segmentation fault
    3. Undefined behaviour
    4. Runtime Error
    5. None of these
Correct Option: C

Undefined behaviour



Your comments will be displayed only after manual approval.