Declaring Structure Tag
In this class, we will try to understand Declaring Structure Tag.
We have already covered the basics of structures in our previous classes.
Table of Contents
Declaring Structure Tag
So far in our previous classes, we have seen only one structure has been created in our examples.
What if we want to create more structures?
The image below is the programming example with two structures that looks the same, but one is for students, and another is for teachers.
In such cases, to avoid confusion among the structures, C provides a facility called structure tags.
A Structure tag is a name used to identify a particular kind of structure.
Example for Declaring Structure Tag
The image shows how structure tags can be declared.
The structure tags are to be mentioned beside the struct keyword.
Now we named the two structures, one as a student and the other as a teacher.
So far, we have declared the structure tags, but we haven’t declared the variables for those structures.
A very important point to understand is the memory for the structures will not be created if we haven’t created the variables.
The image below shows how we create the structure variables for student and teacher structure types.
In the above declaration of the structure, variables have to use the struct keyword, because it shows that student and teacher is structures