Previously, I had an incorrect idea that the collection of local variables occurred when the function was returned. In fact, when the block ends, the content used in the block will be recycled.
The following examples illustrate the problem
* P [(I =; I <; ++ item = &, p [], p [, * p [], * p []);
Output at a time (the specific memory address may be different, but we still find that p [0] and p [1] point to the same place)
P [] = 000000000023FE2C p [] = * p [] = * p [] =
The discovery process of this problem is that when struct is used, the user is too lazy to manually release the memory, and tries to put it in the stack. He wants to automatically recycle it when the function exits. The variables defined in the for block are recycled continuously, and all the variables are at the same address. The problem is more confusing if it is encapsulated by struct.
Typedef main (argc, ** p [(I =; I <; ++ = &, p [], p [, p []-> item, p []->
Output:
P [] = 000000000023FE20 p [] =]-> item = p []-> item =