What is the main difference between STRUCTURE and UNION?

Answer Posted / asesh k tripathy

The difference between union and structure can be as follows:
1. The way structure occupies memory for its member is different from union.
(a) Structure occupies appropriate separate memory for its members
(b) Union occupies memory for that member which needs largest chunk of bytes.
2. We can initialize any of the structure members while initializing any of the union member other than the first member may have unpredictable results.

Is This Answer Correct ?    57 Yes 21 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How to palindrom string in c language?

8923


could you please send the program code for multiplying sparse matrix in c????

3085


Sir... please give some important coding questions asked by product companies..

1811


how to create a 3x3 two dimensional array that will give you the sums on the left and bottom columns

3136


Write a routine to implement the polymarker function

4398






Set up procedure for generating a wire frame display of a polyhedron with the hidden edges of the object drawn with dashed lines

3041


why nlogn is the lower limit of any sort algorithm?

2388


Given a spherical surface, write bump-mapping procedure to generate the bumpy surface of an orange

2872


Can you send Code for Run Length Encoding Of BMP Image in C Language in linux(i.e Compression and Decompression) ?

3868


What is the difference between proc means and proc tabulate ? explain with a simple example when you have to use means or tabulate?

3722


Cluster head selection in Wireless Sensor Network using C programming language.

3125


write a simple calculator c program to perform addition, subtraction, mul and div.

3162


#include int main(void) { int a=4, b=2; a=b<>2 ; printf("%d",a); return 0; }

1086


can you use proc sql to manpulate a data set or would u prefer to use proc report ? if so why ? make up an example and explain in detail

2345


Hi, i have a project that the teacher want a pyramid of numbers in C# or java...when we click a button...the pyramid should be generated in a listbox/or JtextArea...and the pyramid should have the folowing form: 1 232 34543 4567654 567898765 67890109876 7890123210987 890123454321098 90123456765432109 0123456789876543210 Plz help with codes...didn't find anything on the net.

2698