Typedef in C programming

Typedef in C

What is typedef in C?

Typedef  is mechanism of providing alias name to the existing data types. We can use this alias name later in the program whenever we need to use the particular data type.

How to use typedef in C (in simple programs).

OUTPUT:

Description:

  • So in the above program data type in is declared using typedef. Hence length is alias name of int.
  • By using alias name length l and b is declared which will be of integer type. Since length is alias name of int.

Typedef in Structure:

OUTPUT:

You might have observed I didn’t use the struct key word while creating the copy of the object. It is possible because I used the typedef keyword while declaring structure.So if typedef is used while declaring structure no need to use struct while creating copy.

Finally you have got idea about typedef keyword.




     

Leave a Reply