What is the difference between struct and union in C?

Answer Posted / hrpynux@gmail.com

A struct is a block of memory that stores several data objects, where those objects don't overlap. A union is a block of memory that stores several data objects, but has only storage for the largest of these, and thus can only store one of the data objects at any one time.

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is malloc and calloc?

576


How do you sort filenames in a directory?

716


What are void pointers in c?

575


What is data types?

642


How can I ensure that integer arithmetic doesnt overflow?

609






What is a lvalue

665


What are the disadvantages of a shell structure?

696


Can a local variable be volatile in c?

579


What is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?

734


Why is it that not all header files are declared in every C program?

684


what are the 10 different models of writing an addition program in C language?

1442


can we have joblib in a proc ?

1657


What are header files and what are its uses in C programming?

639


Explain what is wrong in this statement?

635


How are variables declared in c?

600