typedef in C
In this class, we will try to understand typedef in C.
We have seen how to declare a structure tag in our previous class.
typedef in C
The image is the use of a structure tag and the declaration of variables for those structures.
In the above declaration, we use the keyword struct for all the variable declarations.
In C, we have a provision to define the data types, which the typedef can do.
The typedef is used to create an additional name for the existing data type but does not create a new type.
For example, we want to create a new definition for int data type as an integer.
The image below shows how to create the type definitions.
We can now use Integer for our variable declaration instead of int, as shown below.
The use of typedef is frequently used for structures.
The declaration of the student structure with typedef is as shown below.
Now in the variable declaration, we can avoid the use of struct student as shown below.