1.typedef: The typedef is used to give data type a new name. For example,
// After this line BYTE can be used // in place of unsigned char typedef unsigned char BYTE; int main() { BYTE b1, b2; b1 = 'c'; printf("%c ", b1); return 0; }
2.How to use the typedef struct in C
Syntax
Method one:
struct Point{ int x; int y; }; typedef struct Point Point; int main() { Point p1; p1.x = 1; p1.y = 3; printf("%d \n", p1.x); printf("%d \n", p1.y); return 0; }
Method two:
typedef struct Point{ int x; int y; } Point; int main() { Point p1; p1.x = 1; p1.y = 3; printf("%d \n", p1.x); printf("%d \n", p1.y); return 0; }