Diagram of this pointer situation?

1
2
3
4
5
6
7
8
9
10
	int firstvalue = 5, 
	int secondvalue = 15;
	int * p1, * p2;

	p1 = &firstvalue;  // p1 = address of firstvalue
	p2 = &secondvalue; // p2 = address of secondvalue
	*p1 = 10;          // value pointed by p1 = 10
	*p2 = *p1;         // value pointed by p2 = value pointed by p1
	p1 = p2;           // p1 = p2 (value of pointer is copied)
	*p1 = 20;          // value pointed by p1 = 20 


This code is obviously taken from the reference section.
I'm asking if someone can make a diagram of this code, my professor showed me a little bit of it but I never really got it.

It's something like this:

[something[something]->[something[something]->NULL

I just don't understand statements like "value pointed by p1 = 10".

If it's possible to upload a picture too, that would be great
Topic archived. No new replies allowed.