Tutorial by Examples

You can give alias names to a struct: typedef struct Person { char name[32]; int age; } Person; Person person; Compared to the traditional way of declaring structs, programmers wouldn't need to have struct every time they declare an instance of that struct. Note that the name Pers...
For giving short names to a data type Instead of: long long int foo; struct mystructure object; one can use /* write once */ typedef long long ll; typedef struct mystructure mystruct; /* use whenever needed */ ll foo; mystruct object; This reduces the amount of typing needed if the ...
We can use typedef to simplify the usage of function pointers. Imagine we have some functions, all having the same signature, that use their argument to print out something in different ways: #include<stdio.h> void print_to_n(int n) { for (int i = 1; i <= n; ++i) printf(...

Page 1 of 1