646 views
0 votes
0 votes
Now I suppose if i have a statement like *P++ then it is broken down  as first (P++) and then *p

(because both are unary operator and associtivity is right to left )

and if we have statement like a=*p++ then it is broken down into a=*p and then p is incremented !!

Am i right ?

2 Answers

2 votes
2 votes
Postfix operator having higher priority than dereferencing operator.

so P++ (dont increment P, use P value as it is . after whole operation increment it).

Then a = *P

Now P++..

Postfix is left to right associative while * is right to left.
1 votes
1 votes
Case 1:

int a,b ;
int *p =&b;
b=9;
printf("%d",*p++);

Case 2:

a=*p++;
printf("%d",a);

 

Both are giving op 9 only

Related questions

3 votes
3 votes
1 answer
1
Storm_907 asked Apr 16, 2023
441 views
Please explain this question void main() { int a =300; char *ptr = (char*) &a ; ptr++; *ptr=2; printf("%d" , a); }
4 votes
4 votes
4 answers
3
Manoj Kumar Pandey asked May 22, 2019
797 views
https://gateoverflow.in/?qa=blob&qa_blobid=14433986388826671915int main() { int a = 10; int *b = &a; scanf("%d",b); printf("%d",a+50); }What will be the Output of the fol...