help in understanding a simple pointers example code.. (i posted this also in the beginners branch)

#include <iostream>


using namespace std;

void main()
{ int *p;
int *pa;
pa=new int[100];
for (int i=0;i<100;i++)
pa[i]=2*i;

p=pa;
cout<<p[0]<<endl;

p=p+10;
cout<<*p<<endl;

p++;
cout<<p[0]<<endl;

p=p-3;
cout<<p[0]<<' '<<p[3]<<endl;

for (p=pa;p<pa+100;p=p+10)


cout<<*p<<endl;



delete [] pa;




}

i am studying pointers and im really not getting the last for loop written in the code..
The values displayed by the compiler for the whole code is
0
20
22
16 22
0 (i guess the last looping starts here)
20
40
60
80
100
120
140
160
180

I don't get how these are the values. Please help me.Thank you!
Just one thread per question, please: http://www.cplusplus.com/forum/beginner/76174/
Topic archived. No new replies allowed.