28. Typedef : C

Typedef

Typedef in C

It is a revelation to make more limited and significant names for types previously characterized by C like int, float, or char. 


What is typedef in C? 

A typedef is a catchphrase that is utilized to dole out elective names to exist datatypes. We use typedef with client characterized datatypes when names of the datatypes become somewhat confounded to use in programs. It can be utilized to -

  • Give clarity in the code 
  • It makes it simpler to change the hidden information types that you use 
  • It makes the code more understood and simpler to change. 


typedef <previous_name> <alias_name> 


In the punctuation, 'previous_name' is the name of a generally existing variable while 'alias_name' is one more name given to the current variable. 


There are different utilizations of typedef

  • It very well may be utilized with a cluster for the most part with the multi-dimensional exhibit. 
  • It will build meaningfulness. 
  • It very well may be carried out for characterizing a client characterized information type with a particular name and type. 
  • It can likewise utilize a typedef with designs.
  • It very well may be utilized for giving a pseudo name to pointer factors. 


Benefits of typedef -

  • It builds the clarity of the code. In case we are utilizing construction and capacity pointer in our code. 
  • It can utilize similar names for the various kinds in various extensions. 
  • Assuming we utilize the typedef, we don't need to compose a struct catchphrase at the hour of variable declaration. 
  • It builds the transportability of the code.

Post a Comment

0 Comments