Reyiz's blog

By Reyiz, 11 years ago, In English

Output of the following code is:

3
2 2 5

I couldn't understand why ((*p)++)+(++(*p)) won't increase a[0] twice. Please help.

Thanks in advance.

#include <cstdio>
int a[2]={1,5};
int main()
{
  int *p;
  p=a;
  printf("%d\n",((*p)++)+(++(*p)));
  printf("%d %d %d\n",*p,a[0],a[1]);
  return 0;
}

Full text and comments »

  • Vote: I like it
  • -18
  • Vote: I do not like it

By Reyiz, 12 years ago, In English

Do you know when it will be fixed?

Full text and comments »

  • Vote: I like it
  • -3
  • Vote: I do not like it