i cant understand what does ++*++p means???
can u help me

mvmalderen commented: Yes, start a new thread about it! -2
siddhant3s commented: Atleast He followed the advice. +14
Nick Evan commented: No he didn't. Mod split it off another thread :) -4

Recommended Answers

All 5 Replies

i cant understand what does ++*++p means???
can u help me

Consider the following code:

#include <iostream>

int main()
{
  int a[5] = {0, 5, 2, 3, 4};
  int *p = a;
  
  ++*++p;
  std::cout << a[1] << std::endl;
  
  return 0;
}
/* Output:
6
*/

Explanation:
The first ++ will increase the value on its right side (*++p).
According to the rules of precedence, ++p will be executed before the pointer is dereferenced, so the pointer (which was pointing to the first element (element 0) of the array) now points to the second element (element 1) of the array, then the pointer is dereferenced.
The value (that we got by dereferencing that pointer) will now be increased by one.

commented: Good explanation of ++*++p - I learned something new too :P +3

thanx

Member Avatar for jencas

Chances of getting an answer is even greater if you give your request a meaningful title.

Chances of getting an answer is even greater if you give your request a meaningful title.

He couldn't help it, first he hijacked a thread, then a moderator was informed to split this into a new thread, and the thread's title was decided by a moderator.

That was the title of the original thread.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.