Summary - structure



  1. C language also provides the flexibility to create new types, known as user-defined types.
  2. User-defined types can be created by using structures, unions and enumerations.
  3. Unlike arrays, the data of different types can be grouped together and stored by making use of structures.
  4. A structure is a collection of variables under a single name and provides a convenient way of grouping several pieces of related information together.
  5. The structure definition defines a new type, known as structure type.
  6. The structure declaration-list in a structure definition consists of declarations of one or more variables, possibly of different types.
  7. A structure declaration-list cannot contain a member of void type or incomplete type or function type.
  8. A structure definition cannot contain an instance of itself.
  9. A structure definition may contain a pointer to an instance of itself. Such a structure is known as self-referential structure.
  10. Structure definition does not reserve any space in memory.
  11. It is not possible to initialize the structure members during the structure definition.
  12. The structure members cannot be initialized during the structure definition, but the members of a structure object can be initialized by providing an initialization list.
  13. An unnamed structure type is also known as an anonymous structure type.
  14. The member of a structure object can be accessed by using: direct member access operator or indirect member access operator.
  15. A structure object can be assigned to a structure variable of the same type.
  16. An assignment operator when applied on structure variables performs member-by-member copy.
  17. The members of a structure object can be byte aligned or machine-word boundary aligned.
  18. If the members of a structure object are machine-word boundary aligned, the padding bytes can appear in between two structure members or after the last structure member.
  19. The sizeof operator when applied on a structure object includes the space taken by internal and trailing padding.
  20. The use of the equality operator on operands of a structure type is not allowed.
  21. An operation that is applicable on an object of a particular type can be applied on a structure member of that type.
  22. Like a pointer to any other type, it is possible to create a pointer to a structure type as well.
  23. It is possible to define a structure type within the declaration-list of another structure-type definition.
  24. Unions are similar to structures except that memory is shared among all the members.
  25. The amount of memory allocated to a union object is the amount necessary to contain its largest member.
  26. Only the first member of a union object can be initialized.
  27. Unions are extensively used in interrupt programming.
  28. Enumerations provide another way to create a user-defined type. An enumeration type is designed for variables that can have a limited set of values.
  29. In a structure or a union declaration-list, it is possible to specify for a member, the number of bits that it will take in the memory. Such a member is called a bit-field.
  30. Bit-fields help in packing several objects into a single unit.

Post a Comment

Previous Post Next Post