Linux manual
page of operator
define as same priority
for both pre/post increment
.
! ~ ++ -- + - (type) * & sizeof right to left
post increment rule is first assigned and then increment
int j = i++;// here first whatever i value is there that will be assigned to j
Pre increment rule is first increment and then assign
int j = ++i;//++i itself will change i value & then modfied value will assign to j.
for e.g consider below example
#include<stdio.h>
int main()
{
int x = 10;
int *p = &x;// assume p holds 0x100
printf("x = %d *p = %d p = %p\n",x,*p,p);
++*p++;
/** in above statement ++ and * having same precedence,then you should check assocaitivity which is R to L
So start solving from Right to Left, whichever operator came first , solve that one first
first *p++ came , again solve p++ first, which is post increment,so address will be same
*0x100 means = 10
now ++10 means = 11
**/
printf("x = %d *p = %d p = %p\n",x,*p,p);
}