Wednesday 14 July 2010

Differences between Structure and Union




Structure
Union
4.       Structure stores different types of data in different locations. That is each member within a structure is assigned its own unique storagr area.
5.       All members can be accessed at a time
6.       The memory size of the structure variable is the sum of the sizes of its members.
4.       Union stores different types of data in a single memory location tha are the members that compose    a union all share the same storage area.
5.       Only one member of the union  and thus one data type can be accessed  at any one time
6.       The memory size of the union variable is the largest size of its members
                                                                   
You may like the following posts:

Derived Data types:
          Structures
             typedef
                 Bit fields
          Unions
User Defined Data types:
         Enum or Enumerations

No comments:

Post a Comment