Boundary alignment: On the machine that requires boundary alignment, the starting position of integer value storage can only be certain bytes, usually a multiple of 2 or 4.
The value of a variable is the value stored in the memory location allocated to the variable, even the pointer is no exception.
A common error:
Int *;
* A = 12;
The following statement stores 12 in the memory location pointed to by.
Here, we name a pointer variable a but haven't initialized it, so we cannot predict where 12 is stored. This operation is very dangerous. This is a case of a wild pointer.
You can obtain the value pointed to by the unreferencing operation on the pointer. However, the NULL pointer does not point to anything. Therefore, it is invalid to unreference NULL in the operating room. Therefore, before unreferencing a pointer, ensure that it is not a NULL pointer.
* & A = 25;
Assign the value 25 to variable. & Operator generates the address of variable a, which is a pointer constant. * operator accesses the address indicated by its operand. In this expression, the operand is the address of a, so the value 25 is stored in.
* 100 = 25;
This statement is incorrect. In the first place, we thought it was to store the value 25 at the position of 100. In fact, it is not because of unreferencing. (indirect access operations can only be used for pointer expressions, cannot be used for integer type). If you want to store 25 at location 100, you must use forced type conversion to convert the integer type to pointer type.
* (Int *) 100 = 25; (this is better * (int * const) 100 = 25 ;).
The result of the & operator is a right value, which cannot be used as the left value. When the expression & ch is evaluated, where should the result be stored in the computer? This expression does not identify any specific location of the machine memory, so it is not a legal left value.