*)*(int
*)0x02000000)
=
(Character
*)malloc(20)
Understand as follows:
Step 1: 0x02000000 is regarded as a big integer.
Step 2: Then (int
*)0x02000000
It becomes a pointer to the address space where integers are stored, and the first address of the address space is 0x02000000.
Step 3: *(int
*)0x02000000
Then take the data in the address space mentioned in the second step, which is an integer (I don't know specifically).
Step 4: (Characters
*)*(int
*)0x02000000
Is to use the integer obtained in the third step (char
*) Forcibly convert the type into a pointer to the address space where char type characters are stored, and the first address of the space is the integer obtained in the third step.
In the fourth step, the current initial first address pointed by the pointer is the integer obtained in the third step.
then
After ((character
*)*(int
*)0x02000000)
=
(Character
*)malloc(20)
; After that,
The pointer is reassigned to a space of type char with a size of 20 bytes, and then the pointer points to the first address of the new space.
Besides, what you said:
Internationalorganizations (same as international organizations)
a = 0x6868
tea
str[]
=
"hello";
((char
*)a)
=
str
Is to convert the forced type of the integer A into a pointer to the char type, and the initial address of the pointer is 0x6868.
Then ((char
*)a)
=
Str This means that the pointer is redistributed, and it points to.
The first address in the "hello" address space.
The above is ok in C.
But in c++, cast is no longer allowed as a left value.