The "typedef" keyword can be used to assign another name for a type declaration. This is often used in "C" to make declarations easier to use. Ex:
#include<stdio.h>
main()
{
int x1 ;
int* ptr1 ;
x1 = 100 ;
printf("x1 value is %d\n" , x1 );
ptr1 = &x1 ;
printf("%d \n" , *ptr1 );
}
Outpt:
100
100
In the above example we are using an integer type and a pointer to an integer type. We can rewrite the above program as:
#include<stdio.h>
main()
{
typedef int INTEGER ;
typedef int* POINTER_TO_INTEGER ;
INTEGER x1 ;
POINTER_TO_INTEGER ptr1 ;
x1 = 100 ;
printf("x1 value is %d\n" , x1 );
ptr1 = &x1 ;
printf("%d \n" , *ptr1 );
}
The above example shows the declaration of "typedef" and it's usage. It's as if we had new types.