Today, I accidentally saw a post posted by my dear friend, saying that no one has made it in the three provinces in northeast China.
What is the result of the following C code running in VC ++ 6.0? Describe the cause in detail.
# Include <stdio. h>
Int main ()
{
Int a [5] = {1, 2, 3, 4, 5 };
Int * ptr1 = (int *) (& a + 1 );
Int * ptr2 = (int *) (int) a + 1 );
Printf ("% x, % x", ptr1 [-1], * ptr2 );
Return 0;
}
The first one is the question of & a + 1. It is obvious that the answer to ptr1 [-1] is "5 ".
The second question * ptr2 is very interesting.
0x00000001 and 0x00000002 are arranged in the memory as follows:
0x0000000 and 0x20000000
The two rows are 0x0100000020000000 together.
So (int) the pointer to a + 1 is 0x20000000 in the memory.
This topic is quite interesting. Let's take a look at it. ^_^
If you want to recruit embedded students, you can still go to Southwest University of Science and Technology to check out. Although not all of them have done this, some people can do it. Haha, I am not looking for a job yet... It would be better if we come to our school to test this question ^_^