SPOT THE ERROR....!

Hi,
I have a life changing exam today(its 12.45am here). Now i bumped in a sample question i have collected. It prompts to correct the error but i cant find any... Can you please help me..
1
2
3
4
5
6
int i,p[]={1,2,3,4};
for(i=0;i<4;i++)
{
 cout<<*p;
 p++;
} 


I know that 'p' points to case address of array and can't find any problems with pointer arithmetic... Please help. Thanks for patience...
Last edited on
You can't increment p, either copy it[1] or use i[2]:
[1] http://ideone.com/WoCCGI
[2] http://ideone.com/PElFFQ
why cant you increment p?
An array name isn't the same as a pointer, it isn't an lvalue http://ideone.com/UE5Ujy
http://www-ee.eng.hawaii.edu/~tep/EE160/Book/chap7/subsection2.1.3.2.html
oh,Thanks guys I never knew that fact....Now i can nail that kinda questions....Thanks all...
Topic archived. No new replies allowed.