Typedef in C


typedef is a keyword in the C language. C language facilitates programmers to assign a new name to the existing data types. typedef keyword is used for the purpose of assigning a new name to a type.

It reduces the workload of programmers as it prevents them from writing more.

For example, we want some variables of type unsigned int. Suppose the variables are a, b, c, d, e, f. Then the declaration statements for these variables will be like

unsigned int a;

unsigned int b;

unsigned int c;

unsigned int d;


Don’t you think it is very hectic to write such a large data type again and again? But we have one more way to overcome this complex syntax.

We can use the typedef keyword to assign a new name of our choice to unsigned int. That particular name can be used anywhere in the program in place of ‘unsigned int’.


The syntax to be used while using typedef keyword is

typedef current_name new_name;


typedef unsigned int unit;

unit a, b, c, d, e, f;

The above-written code changes the name of ‘unsigned int’ to ‘unit’. Thus, we use the ‘unit’ type to declare the variables that are a, b, c, d, e, f.


int main()
typedef unsigned int unit;
unit i=10;
unit j=20;
return 0;



The above-written code works fine. So, we can use the typedef keyword to change the name of any data type.


Leave a comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.