C Programming - Structures, Unions, Enums - Discussion

Discussion Forum : Structures, Unions, Enums - Point Out Errors (Q.No. 8)
8.
Point out the error in the program?
#include<stdio.h>

int main()
{
    union a
    {
        int i;
        char ch[2];
    };
    union a z1 = {512};
    union a z2 = {0, 2};
    return 0;
}
Error: invalid union declaration
Error: in Initializing z2
No error
None of above
Answer: Option
Explanation:
No answer description is available. Let's discuss.
Discussion:
21 comments Page 3 of 3.

Preethi said:   1 decade ago
I guess the variable ch is declared to be as character but int values are assigned to it. Am I correct?.


Post your comments here:

Your comments will be displayed after verification.