Home » C Programming » Structures » Question
  1. What will be the output of the following C code?
    #include <stdio.h>
    struct Worker
    {
    char *name;
    };
    struct Worker w1[2], w2[2];
    void main()
    {
    w1[0].name = "Imaraj";
    w1[1] = w1[0];
    w2 = w1;
    printf("%s%s", w2[0].name, w2[1].name);
    }
    1. Imaraj
    2. Compilation Error
    3. Garbage value
    4. Nothing
    5. None of these
Correct Option: B

Compilation Error

main.c: In function ‘main’:
main.c:11:12: error: assignment to expression with array type
w2 = w1;



Your comments will be displayed only after manual approval.