Structures in C

A structure is commonly referred to as a user-defined data type. C’s structures allow you to store multiple variables of any type in one place (the structure). A structure can contain any of C’s data types, including arrays and other structures. Each variable within a structure is called a member of the structure. They can hold any number of variables, and you can make arrays of structures. This flexibility makes structures ideally useful for creating databases in C. Similar to the structure there is another user-defined data type called Union which allows the programmer to view a single storage in more than one way i.e., a variable declared as union can store within its storage space, the data of different types, at different times. In this tutorial, we will be discussing the user-defined data type structures and unions.

• declare and initialize the members of the structures;
• access the members of the structures;
• pass the structures as function arguments;
• declare the array of structures;
• declare and define union; and
• perform all operations on the variables of type Union.

Leave a Reply

Your email address will not be published.

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: