If u or U is added to an integer constant, it indicates that the constant is an unsigned number. For example, 12345u or 12345u.
If it is-12345u, the computer will first convert-12345 to its complement form 53191, and then store it in the form of unsigned numbers.
If an integer is followed by the letter L or l, it is a long int type constant.
When a computer encounters a decimal number, it will first convert it into a dual-precision data storage (64-bit). Although the accuracy is improved, the computing speed will be reduced. Therefore, if we pay more attention to the computing speed, we can add f or f after the decimal number to tell the computer to process the data according to the single precision. Do not convert the data to double precision.
There are some hidden rules in the hybrid operation of different types of data:
1 char and short must be converted to int before calculation.
2 float is converted to dual-precision type before computation, even if two float data types are added together.
3 if int and double operations are performed, Int Is first converted to double, and then two double operations are performed.
4 if the int and unsigned int operations are performed, the int must first be converted to the unsigned int, and then the two unsigned int operations are performed.
5. These types are automatically converted by the system.
During forced type conversion, an intermediate variable of the required type is obtained. The type of the original variable does not change, such as (double) (x). The type of X does not change.
Single Object operators include :!,~, ++,-,-, (Type), *, &, sizeof
The priority of a single object operator is second only to (), [],->, and. (Not true) operators.
The Union of a single object operator is from right to left. For example,-I ++, that is,-(I ++); for example, * I ++, that is, * (I ++ ).
The C compilation system uses greedy methods to identify operators, such as I ++ J. It is understood as (I ++) + J.
The comma expression is like expression 1 and expression 2.
The value of a comma expression is the value of expression 2.
Since the value assignment operator has a higher priority than the comma operator, a = 3*5, a * 4 is interpreted as (A = 3*5), a * 4
The comma operator is basically the operator with the lowest priority, while the value assignment operator is basically the second-to-last operator. (The last one in the class is a comma. Assign values to the second-to-Second Class, huh, huh. You must know who is the third-to-last class. Tell you that the conditional operator is the only three-object operator in C "? :".
There are 6 Relational operators in the C language:
<, <=,>, >=, = ,! =. The priority of the first four types is higher than that of the last two types.
The C language provides three logical operators:
&, | ,!, These three priorities are different ,! The highest priority, followed by & | the lowest priority. What's more complicated is that the priority of & | is lower than that of the relational operator! Higher than Arithmetic Operator
The summary is as follows:
Comma operator <value assignment operator <||<&< relational operator <arithmetic operator <!
All operators with the right-to-left combination include assignment operators, single-object operators, and conditional operators. For example, A> B? A: C> D? C: D, that is, A> B? A :( C> D? C: d)
The scanf function uses spaces as the Terminator. So scanf ("% s", STR,
If the input is how are you? In this case, only how is stored in Str. Pay special attention to this.
The shared body is defined:
Union shared body name
{
Member list;
} Variable list;
For example:
Union data
{
Int I;
Char ch;
Float F;
} A, B, C;
The Memory Length occupied by the shared body variable is the longest member length.
When referencing a shared body variable, pay attention to which member is currently stored in the shared body variable.
& A, & A. I, & A. Ch, and & A. F are all the same address values.
You cannot assign values to the shared body variable name or reference the variable name to obtain a value. You Cannot initialize the shared body when defining it.
The concept of bit segments is very important and is often used in network programming.
Struct packet_data
{
Unsigned A: 2;
Unsigned B: 6;
Unsigned C: 4;
Unsigned D: 4;
Int I;
} Data;
Of course, it may not occupy exactly one byte, such
Struct packet_data
Unsigned A: 2;
Unsigned B: 3;
Unsigned C: 4;
Int I;
} Data;
In this case, A, B, and C occupy the first nine digits of the two bytes, And the last seven digits will be idle, and I will start from the beginning of another new byte.
When referencing a bit field, pay special attention to its maximum value range. If it occupies 2 places, the maximum value is 3.
The type of a member can only be set to unsigned Int or Int.
To force a domain to start from the new byte, you can do this:
Unsigned A: 1;
Unsigned B: 2;
Unsigned: 0;
Unsigned C: 3;
C is stored from a new byte.
Bit segments can be output using % d.
You can define an anonymous field, indicating that these digits are not needed:
Unsigned A: 1;
Unsigned: 2; // these two spaces are not used
Unsigned C: 3;