I wrote a few notes about the blind spots in my C language. I only thought that I had experienced and had errors.
1. What is the logical expression value? Expression 1: expression 2; for example, x = y> z? Y: z
2. The priority of logical operators such as "+,-" is greater than that of shift, and the shift is greater than that of logical operations.
3. sizeof is completed by the compiler during compilation and does not perform computation on the input parameters. Sizeof (I ++); 4 is returned; the difference between sizeof and strlen operations on actual I is that the latter is executed during computation. Returns the number of non-NULL characters. When sizeof processes array names, it counts the allocated memory size. For example, if a [12] ={}; then sizeof (a) = 12; for example, a [] = "aaa ", the compiler allocates 4 memories to store data. sizeof (a) = 4;
4. Force type conversion prior to +,-. Therefore, the auto-increment operation will be different after the pointer type changes;
5. invalid combination of type specifiers combination of invalid Types. The main cause is that multiple data types define and typedef in the header file cause errors.
Typedef is a type redefinition. It is not a macro value redefinition. It can only be used for replacement of types. |
, Mainly in the compilation stage, with a semicolon
Define is a macro definition. It is mainly used in the pre-processing stage and is not suitable for type conversion. The end semicolon will be replaced with a macro, for example, define # define Uint8 unsigned char typedef xdc_Uint8 Uint8; the macro is replaced with typedef xdc_unsigned char Uint8, which leads to invalid type combination. Therefore, the define macro is a replacement of preprocessing, while typedef is a real conversion and definition of data types. It is best not to convert a macro into a typedef !!!. When multiple data types are defined, be sure not to encounter the above situations
6. printf outputs the % number, which must be printed using printf ("% \ n ");
7. Logic or operation or remember:
| And |, and use of & and.
8. Get non! And ~ Calculation priority of '+ -;
9 strcpy refers to copying the number of bytes from the source address to the end of \ 0 to the destination address. The number of bytes counted by strlen from the source address to the number of bytes before \ 0 is not counted as \ 0
10. A position: 1 A | = (1 <5); A position: 0 A & = ~ (1 <5); A certain digit is A ^ = (1 <5); it is different from 1 or inverse.
11. The a. B operation is required for union assignment.
12, 0x % 08x, the output hexadecimal number must reach 8 bits, otherwise add 0 in front
14. Stack frames include the function parameters required for another frame, the returned pc address, and the ebp of the current frame.
15. struct alignment struct test {char x1; short x2; float x3; char x4 ;}; by default, the compiler will align the struct with the natural boundary (Some people say "natural to the boundary", I think the boundary is more convenient, the offset address is 0, occupying 1st bytes. The second member x2 is of the short type, and its starting address must be two byte pairs. Therefore, the compiler fills a Null Byte between x2 and x1. The third and fourth members of the structure exactly fall on their natural boundary addresses, and no additional bytes are needed before them. In the test structure, member x3 requires a 4-byte bounded boundary and is the maximum boundary unit required by all members of the structure. Therefore, the natural boundary condition of the test structure is 4 bytes, the compiler fills in three NULL bytes after Member x4. The entire structure occupies 12 bytes of space.
16. memset () is to set n Bytes to an input byte such as memset (a, 0,100); memcpy (dst, src, n ); copy the n Bytes starting with src to the destination.
17. The global variables in the dynamic link library referenced by multiple processes are independent of each other and have their own text and data. The global variables are located in the data segment, so there will be no competition.
18. struct is a struct array declaration and definition method. Static struct {char * name;
Int offset ;}_ reg_list [] = {};
A