C Programming - Structures, Unions, Enums - Discussion
Discussion Forum : Structures, Unions, Enums - Yes / No Questions (Q.No. 2)
2.
size of union is size of the longest element in the union
Discussion:
5 comments Page 1 of 1.
Mehul said:
1 decade ago
I dont think so
union a
{
int a;
char ch[2];
}
size if a is 6 here and acc to you it should be 4
union a
{
int a;
char ch[2];
}
size if a is 6 here and acc to you it should be 4
Shubham said:
1 decade ago
Max size of the union is the size of the largest data type or the memory taken by largest member.
If you want you may check it on GNU C Compiler.
If you want you may check it on GNU C Compiler.
Bhakar said:
1 decade ago
Cause in union one time one variable we can use.
union a
{
int a;
char b;
}a;
max size of union = integer size;
union a
{
int a;
char b;
}a;
max size of union = integer size;
Zainab said:
1 decade ago
Please explain.
Aaradhana said:
1 decade ago
Can anyone tel why is it so?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers