A ++ and ++ A, the prefix and suffix can be used as the left value. This problem has made me busy for a long time and finally made some breakthroughs.
A ++ and ++ A are different when doing the left value. Therefore, the left value must first have a specific address before it can be used as the left value. Otherwise, no specific object is assigned. Let's take a look at a ++ and ++. A ++ means to copy a temporary data to participate in the calculation of the surrounding environment, and then add the variable, it can be seen that a ++ is used to perform computation on a temporary copy of data. This data temporarily exists without a fixed address, rather than a real variable. ++ A means to add the variable a first and then place the variable in the surrounding environment for calculation. Then ++ A is used to calculate the variable with a specific address, therefore, ++ A can be used as the left value.
It can be understood:
A ++ returns a temporary variable.
++ A returns a reference to a variable.
Notes:
Calculating the space occupied by a struct does not simply add the space occupied by each member. Considering the requirements of system boundary alignment, the sizes of the following two structs are not the same.
Struct funp
{
Int;
Char B;
Char C;
};
The size is 8 bytes.
Struct funp
{
Char B;
Int ;;
Char C;
};
The size is 12.
The size of the above two struct types is 8 bytes and 12 bytes respectively, which is not a simple addition of 6 bytes. We need to consider the 4-byte alignment.
A ++ and ++ a left values