INDEX

2.29.2012

Q . Write and explain the significance of "typedef datatype" in c programming with example.

Ans.

In C typedef is a keyword.

Keyword typedef stands for type definition.

It is used for create an alias name of existing data type. typedef is used by writing the keyword typedef, followed by the existing data type and then the new name.

Syntax:

typedefexisting_daya_type new_name ;

Example:

typedefchar ch;

In above example, i has defined ch as char, so now i could perfectly use ch as declarations of any other valid types:

ch yourchar;ch mychar,*str;

Note:-typedef does not create different types. It only create synonyms of existing data types i.e. in our example the type of mychar can be considered to be either ch or char, since both are in fact the same type.