increment of pointer??

int a[4] = {2,4,6,8};
int * pointer = &a[1];

then please explain this : *p++
http://en.cppreference.com/w/cpp/language/operator_precedence

This is the same as *(p++)

So it increments the pointer, then dereferences. By incrementing, it is in this case now pointing at a[2]. Dereferencing should return a 6 at this point.
Like all other C++ operators, ++ returns a value:-

If ++ precedes the variable, e.g. ++counter, the value returned is the value in counter after it has been incremented.
If ++ follows the variable, e.g. counter++, the value returned is the value in counter before it has been incremented.

http://www-numi.fnal.gov/offline_software/srt_public_context/WebDocs/Companion/cxx_crib/increment.html

This link should be helpful also
http://www.cprogramming.com/tutorial/lesson6.html
Topic archived. No new replies allowed.