#define and typedef and define the difference between finishing

(1) #define a macro definition command (allowing C or C ++ source code used in an identifier to indicate a character string called "macro")

                                                                                                     Identifier: it means a symbol used to identify an entity

                 When the preprocessor replaced

                                                    例:#define      PI     3.141592653

                                                                      (Identifier) ​​(String)

                                                               S = PI * r * r;

                                                              The PI 3.141592653 replaced when the preprocessor.

(2) typedef (declared type, keyword)

                                 When used with the structure struct, the format:

                                              typedef     struct{

                                                                       ......

                                                                       } Dog;

                        The complex is defined as a statement alias , the purpose of the source code easier to read and understand.

                        The structure is struct {.......} this section, with "dog" indicates, when used in the structure, the direct use of a "dog" can represent a large segment of code structure.

 

Supplementary: ① Note: #define last no semicolon;

           ② # parameters used to convert into a string;

               ## is used to connect the front and rear two parameters, turning them into a string

          ③ structure struct definition:

                               struct 结构名

         {

         //成员表列,就是数据集合

         };

Guess you like

Origin blog.csdn.net/lexiaowu/article/details/81193924