+ 1

What do you mean by typedef?

25th Feb 2018, 4:29 PM
Puneet Bhardwaj
Puneet Bhardwaj - avatar
2 Answers
+ 6
Quoted: "Typedef is a keyword that is used to give a new symbolic name for the existing name in a C program". Read the details at the following link: https://fresh2refresh.com/c-programming/c-typedef Hth, cmiiw
25th Feb 2018, 5:00 PM
Ipang
+ 3
It basically renames a type. It is useful when there is some variable with a primitive data type (int,char,float,...) but the content is not meant to be interpreted by us as a N-bit number (as the datatype suggests) so you may want to rename the data type to something you understand. For example, a char data type could store the red channel of a pixel of some image, but also the blue one so you may get confused with so much chars. Then, you could do something like typedef char REDNESS; typedef char BLUENESS; typedef char GREENNESS; and then use them as regular data types, like so REDNESS pixRedVal = 255; BLUENESS pixBlueVal = 255; GREENNESS pixGreenVal = 255;
25th Feb 2018, 4:51 PM
Bebida Roja
Bebida Roja - avatar