TypeDef in C

TypeDef in C

  • The C programming language provides a keyword called typedef, by using this keyword you can create a user defined name for existing data type.
  • Generally typedef are use to create an alias name (nickname).

Declaration of typedef

 typedef datatype alias_name; 


typedef int intdata;

Sample Code

typedef int intdata; 
void main()
          int a=10;
          typedef intdata integerdata;
          integerdata b=20;
          integerdata s; 

Read Also

TypeDef in linux

Code Explanation

  • In above program Intdata is an user defined name or alias name for an integer datatype.
  • All properties of the integer will be applied on Intdata also.
  • Integerdata is an alias name to existing user defined name called Intdata.



Advantages of typedef:

  • It makes the program more portable.
  • typedef make complex declaration easier to understand.

TypeDef With Struct

  • We have to include keyword struct every time you declare a new variable, but if we use typedef then the declaration will as easy as below.


typedef struct{
	int id;
	char *name;
	float percentage;
student a,b;

Related Searches to TypeDef in C

Adblocker detected! Please consider reading this notice.

We've detected that you are using AdBlock Plus or some other adblocking software which is preventing the page from fully loading.

We don't have any banner, Flash, animation, obnoxious sound, or popup ad. We do not implement these annoying types of ads!

We need money to operate the site, and almost all of it comes from our online advertising.

Please add wikitechy.com to your ad blocking whitelist or disable your adblocking software.