I newly started working with C and Pointers. There is a concept that confuses me regarding to unary increment operation on pointers.
int num1, *pnum1
num1 = 2;
pnum1 = &num1;
printf("%d \n before: " , *pnum1);
num1 = (*pnum1)++;
printf("%d \n after: " , *pnum1);
return 0;
Since the unary increment operator (++) has greater precedence than the dereference operator (*), I put *pnum1 inside braces. What I expect was to see below result:
after: 3
But it doesn't increment the value of num1. Why would it be the case? Wasn't it suppose to increment the value of num1?