×
FREE ASSISTANCE FOR THE INQUISITIVE PEOPLE
Tutorial Topics
X
softetechnologies
structure and union in C - WBUT MCA 2011 - WBUT Semester I
1211    Arnab De    11/12/2019

Compare and contrast between structure and union in C. [WBUT MCA 2011]

Both structure and union are the ADT or Abstract Data Type in C which are bind the one or more different types of data variables within a scope. Those variables are accessed by the corresponding structure or union variables. But there is a simple difference between them.

softetechnologies

Structure can use all the variables within it. I.e. it can store or access the said variables in it at a time. Structure allocates separate memory for each of the variables declared in it. It allocates more memory than union. We declared a structure using the keyword “struct”.

softetechnologies

But in union only one variable of any type can access at a time. It occupies a smaller memory space than a structure. It occupies the same quantity of memory which occupies the largest variable, declared within it. To declare a union, we use the keyword “union”.

softetechnologies
Author Details
Arnab De
I have over 16 years of experience working as an IT professional, ranging from teaching at my own institute to being a computer faculty at different leading institute across Kolkata. I also work as a web developer and designer, having worked for renowned companies and brand. Through tutorialathome, I wish to share my years of knowledge with the readers.
Enter New Comment
Comment History
No Comment Found Yet.
Albert Einstein
Imagination is everything. It is the preview of life's coming attractions.
Albert Einstein
1313
57.24
Today So Far
Total View (Lakh)
softetechnologies
26/05/2018     43530
01/01/2018     36478
25/06/2018     35475
28/06/2017     34547
02/08/2017     32975
01/08/2017     27458
06/07/2017     27205
15/05/2017     26841
14/07/2017     22455
21/04/2018     21107
softetechnologies