Structures & Unions in C

Arrays provide a mechanism to declare a derived data type which is a collection of homogenous elements. This means each element has same data type. However, it is sometimes required to create a collection of non- homogeneous elements in which elements can be of different type. Consider the automation of student records in University of Kashmir. Every record may contain student name, its registration number, address, and so on. It is obvious that the information to be stored is not homogenous. In order to create such kind of records programming languages provides various types of constructs. Specifically, C language provides user-defined data type called struct (Structure). In addition, it also provides another user-defined data type called union. These user-defined data types can be used to create various types of collection of elements in which elements can be of different data types.


For any query or issue, feel free to discuss on http://discuss.eduguru.in