I. Examples
The corresponding function call is int printf (const char * fmt ,...), fmt is a char * pointer type, so it occupies 32 bytes, but * fmt executes one byte and * fmt ++ executes the next byte, & fmt get a 32-bit address, (char *) & fmt get a pointer to the execution byte, (char *) & fmt + 4 right after var3 is executed, because fmt occupies 4 bytes. (Int *) (char *) & fmt + 4), and converts it to a four-byte pointer. In this case, * (int *) (char *) & fmt + 4), the obtained number is changed to 32-bit data, that is, var3.
Conclusion: If the conversion is forced to char *, the pointer ++ moves one byte, and * the pointer gets one byte. If the value is forcibly converted to int *, the pointer ++ is followed by four bytes. At the same time, the * pointer gets 4 bytes.
No matter what type of pointer variable, the difference is obtained after subtraction.
Ii. When to force type conversion
[Cpp]
# Include <stdio. h>
# Include <stdlib. h>
Int main ()
{
Int a = 6336;
Char * B = (char *) &;
Printf ("% d", * B );
Getchar ();
Return 0;
}
# Include <stdio. h>
# Include <stdlib. h>
Int main ()
{
Int a = 6336;
Char * B = (char *) &;
Printf ("% d", * B );
Getchar ();
Return 0;
}
The result is-64, because * B only points to one byte.