Skip to content

C Typedef

Typedef creates aliases for data types.

1. Basic Typedef

c
typedef unsigned int uint;
typedef int* IntPtr;

2. Using Typedef

c
uint number = 100;
IntPtr ptr = &number;

3. Struct Typedef

c
typedef struct {
    char name[50];
    int age;
} Person;

Person person1 = {"John", 25};

4. Function Pointer Typedef

c
typedef int (*Operation)(int, int);

int add(int a, int b) { return a + b; }
Operation op = add;

Content is for learning and research only.