C typedef Keyword
Example
Create a new name for the float type:
typedef float Temperature;
int main() {
Temperature today = 25.5;
printf("%.1f", today);
return 0;
}
Definition and Usage
The typedef keyword creates a new name (an alias) for an existing data type.
In the example, Temperature is just another name for float. The new name makes the code easier to read, because it tells what the value is used for.
It is often used with structures, so that you can write Car myCar; instead of struct Car myCar;.
Related Pages
Read more about typedef in our C typedef Tutorial.