C Advanced: Type definitions

The typedef keyword in C allows you to defined new types.

Starting from the built-in C types, we can create our own types, using this syntax:

typedef existingtype NEWTYPE

The new type we create is usually, by convention, uppercase.

This it to distinguish it more easily, and immediately recognize it as type.

For example we can define a new NUMBER type that is an int:

typedef int NUMBER

and once you do so, you can define new NUMBER variables:

NUMBER one = 1;

Now you might ask: why? Why not just use the built-in type int instead?

Well, typedef gets really useful when paired with two things: enumerated types and structures.

Lessons in this unit:

0: Introduction
1: Input and output
2: Variable scope
3: Static variables
4: Global variables
5: ▶︎ Type definitions
6: Enumerations
7: Structures
8: Command line parameters
9: Header files
10: The preprocessor
11: NULL values
12: Boolean values
13: Nesting functions
14: Conversion specifiers
15: Using quotes
16: String length
17: Returning strings
18: Array length
19: Looping through arrays
20: Checking character values
21: Printing percentage signs
22: Troubleshooting: Implicit function declarations

Join my AI Workshop!

The Web Development BOOTCAMP cohort starts in February 2026