Search⌘ K

Typedef

Explore how to use typedef in C to rename existing data types, including built-in types and structures. Understand the benefits of typedef for creating readable and maintainable code by giving types new, meaningful names. This lesson helps you efficiently define variables using alternative type names.

What is typedef?


The typedef keyword lets us give a new name to an existing data type.


Typedef built-in data types

See the code given below!

C
#include<stdio.h>
int main() {
// Declare variables
unsigned long int i, j;
// Give new name to unsigned long int
typedef unsigned long int ULI;
// Declare variables of type ULI
ULI k, l;
}
...