1. primitive
typedef int Integer;
Integer i;
2. array
typedef int Arr[10];
Arr a, b, c;
3. function pointer
#include<stdio.h>
typedef int (*pfn)(int, int);
void main()
{
int max(int, int);
pfn p;
p = max;
printf("%d\n", (*p)(2,3));
}
How to define typedef?
a. write down the original clause(eg: int i);
b. change the variable name to new type(eg: i -> count), now is 'int count';
c. add 'typedef' in the front, now is 'typedef int count';
d. define int variable with new defined type(eg: count n, m, k;).