Home » C Programming » Structures » Question
  1. What will be the output of the following C code?
    #include <stdio.h>
    struct Employee
    {
    char *ch;
    struct Employee *point;
    };
    void main()
    {
    struct Employee e1;
    struct Employee e2;
    e2.point = e1;
    (e2.point)->ch = "Prayag";
    printf("%s", e1.ch);
    }
    1. Compilation Error
    2. Garbage value
    3. Prayag
    4. Undefined behaviour
    5. None of these
Correct Option: A

Compilation Error

main.c: In function ‘main’:
main.c:11:18: error: incompatible types when assigning to type ‘struct Employee *’ from type ‘struct Employee’
e2.point = e1;



Your comments will be displayed only after manual approval.