#define and typedef definitions

#define 

#defineMacros defined rules for replacing pretreated

In short, # define is the most simple string replacement #define ll long long program will replace all ll to long long and long long program at run time will not appear he had ll ll be construed as acquiescence  

In some c language exam may be some #define ba * 5 #define a 2 + 3 to ask you how much output value of b is not allowed to be understood as a 2 + 3 = 5, but he replaced all the b = 2 * 5 + 3 = 17, here, you may be able to understand the concept of the alternative

Code pre-processing stage before the official compilation, the preprocessor will replace strict code of all "#define" macro definition in accordance played file from where the macro defining the beginning of the end of the encounter or the corresponding "#undef" command until

If the code is defined in the relevant errors with the macro, it will error in the preprocessing stage

typedef=type+def

"Typedef" operation based on an existing data type definition of a new data type, the data type of the original still exists, which recognize and processed by the compiler at compile time. typedef int INT time INT is an int data type

typedef variable definition statement statements = typedef +

Remove typedef, this statement defines a variable

Plus typedef, this variable is what type, then it turned into this type of alias

Other

In the definition of the time pointer typedef

typedef char *ch;

ch a,b;

You define a variable of type char * two is no problem, but if you use #define words

#define ch char *

ch a,b;

It is equivalent to char * a, b; b data you type into a char

 

Guess you like

Origin www.cnblogs.com/YangKun-/p/12518983.html