user152169
user152169

Reputation: 151

Change name of data type in C

Is it possible to change the name of the data type that you will be using in your code? Say, instead of defining "int a", you want to do "my_type a" after telling the compiler that "my_type" = "int". Thanks.

Upvotes: 3

Views: 1723

Answers (1)

Greg Hewgill
Greg Hewgill

Reputation: 994221

Yes, C supports this using a typedef declaration:

typedef int my_type;

my_type a;

Upvotes: 5

Related Questions