typedef keyword

typedef keyword:

Typedef keyword is used to give alternative name to a type in a code and use that in a code.

When it is used ,the name is used as an abbreviation in whole program.

e.g.

In program code, in place of int we can use integer as,

Its output will be 3.

It can also be used for derived data types.

e.g.

Its output will be:

Difference between typedef and define:

1. typedef is just a keyword whereas define is a pre-processor directive for defining macros.

2. typedef is used for alternatively naming types and define is used for macros.

3. typedef instruction is performed by compiler whereas define statements are executed by pre-processor.

Leave a Reply

Your email address will not be published. Required fields are marked *