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 ? Programming in C pointers programming-in-c + – spriti1991 asked Jun 1, 2015 spriti1991 670 views answer comment Share Follow See all 0 reply Please log in or register to add a comment.
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. Digvijay Pandey answered Jun 1, 2015 Digvijay Pandey comment Share Follow See all 6 Comments See all 6 6 Comments reply Show 3 previous comments Arjun commented Jun 1, 2015 reply Follow Share a++ returns the value of a and after this increments a. So whatever printed or assigned to another variable value will be the initial one. Next time we access a, its value will be previous value plus 1 and we are not allowed to access a, until this increment is sure to be done which are guaranteed at places called sequence points. 2 votes 2 votes spriti1991 commented Jun 1, 2015 reply Follow Share Okie got it ! Thanks sir :) 1 votes 1 votes Digvijay Pandey commented Jun 1, 2015 reply Follow Share 1.Int a = 4; Print ("%d", a++) Output will be 4. 2.Int a =4; d= a++ Print ("%d", d) Output will be 4. 3.Int a =4; d= a++ Print ("%d", a) Output will be 5.. In all above cases finally a value is 5 Only. 3 votes 3 votes Please log in or register to add a comment.
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 radha gogia answered Jul 23, 2015 radha gogia comment Share Follow See all 0 reply Please log in or register to add a comment.