×
FREE ASSISTANCE FOR THE INQUISITIVE PEOPLE
Tutorial Topics
X
softetechnologies
structure and union in C - WBUT MCA 2011 - WBUT Semester I
1971    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.
Rabindranath Tagore
It is very simple to be happy, but it is very difficult to be simple.
Rabindranath Tagore
2322
80.75
Today So Far
Total View (Lakh)
softetechnologies
26/05/2018     54110
25/06/2018     45116
01/01/2018     43670
28/06/2017     41205
02/08/2017     40216
01/08/2017     34263
06/07/2017     34062
15/05/2017     33299
11/09/2018     30314
14/07/2017     29827
softetechnologies