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

Compilation Error

main.c: In function ‘main’:
main.c:8:23: error: storage size of ‘emp’ isn’t known
struct Employ emp;



Your comments will be displayed only after manual approval.