C typedef keyword

Using typedef, we can create an user defined name for existing datatype.
Generally using typedef, we can create an alias names.

Syntax:

typedef datatype user_define_name;

Example:

#include
#include
typedef int myint;
int main()
{
int a=10;
myint b=20;
typedef myint smallint;
s=a+b;
printf(“\n Sum of a and b = %d”, s);
getch();
return 0;
}

Output: 30

  • In the above program all properties of integer will be applied to myint also.
  • Smallint is an alias name to existing user-defined name called myint.
Powered by k2schools