Example of typedef in C
typedef long long ll;
Below is the C program to illustrate how to use typedef.
C
// C program to implement typedef #include <stdio.h> // defining an alias using typedef typedef long long ll; // Driver code int main() { // using typedef name to declare variable ll var = 20; printf ( "%ld" , var); return 0; } |
Output
20
C typedef
The typedef is a keyword that is used to provide existing data types with a new name. The C typedef keyword is used to redefine the name of already existing data types.
When names of datatypes become difficult to use in programs, typedef is used with user-defined datatypes, which behave similarly to defining an alias for commands.