Skip to main content

Posts

Showing posts with the label typedef

Typedef Statement in C programming

   C supports a feature known as “type definition” that allows users to define an identifier that would represent an existing data type. The user-defined data type identifier can later be used to declare variables. It takes the general form: typedef type identifier ; Where type refers to an existing data type and identifier refers to the “new” name given to the data type. The existing data type may belong to any class of type, including the user defined ones. The new type is new only in name, but not the data type. typedef cannot create a new type. Some examples of type definition are: typedef int units ; typedef float marks ; Here, units represent int and marks represents float. They can be later used to declare variables as follows: units batch1, batch2 ; marks name1 [50] ; name2[50] ; batch1 and batch2 are declared as int variable and name1[50] and namer[50] are declared as 50 element floating point array variables. The main advantage of typedef ...