Structure is the collection of different data types. It allocates memory for the highest data items. We can access more than one element at a time of all items. We can access the elements of structure by using dot (.) operator in case of normal variable or by using (→) arrow operator in case of pointer.
Unions are concept borrowed from structures and therefore follow the same syntax as structures. However, there is a major distinction between them in terms of storage. In structures, each member has its own storage location; where as all the members of a union uses the same location. This implies that, although a union may contain many members of different types, it can handle only one member at a time. Like structure, a union can be declared using the keyword union as follows:
This declare a variable code of type union item
Typedef statement is only used for making user define keywords. For example,
typedef int amit;
printf("enter a number ");
printf("your entered number is %d",num);
Here, amit become an integer keyword.