Today in C language practice involves the use of TypeDef and define problems, then what is the difference between them? Why use typedef in this case? In which case, why use define?
Did you ever think about it when you were studying C?
Today I decided to comb it for later use.
Same point:
1, you can give the variable alias
Different points:
1, define can be extended after definition, and typedef can not.
1 // 2 3 #define zhengxing int4 unsigned zhengxing; // correct 5 int 7 unsigned zhengxing; // error
#行内代码
1// define an integral type after the data is added to the definition as unsigned
2 3 #define zhengxing int4 unsigned zhengxing; // correct 5 6 int 7 // Error
2, typedef can be defined continuously, define is not.
#define Apple char*//val1 is a pointer type char*, VAL2 is a char type. char *//VAL1 and val2 are all pointer types char*
Follow-up continues to add ...
The difference between typedef and define in C language