Exforsys
+ Reply to Thread
Results 1 to 2 of 2

How is it Evaluated?

This is a discussion on How is it Evaluated? within the C and C++ forums, part of the Programming Talk category; I want to know how *p++ gets evaluated as p being declared as a integer pointer. If anyone could explain ...

  1. #1
    cyrus is offline Senior Member Array
    Join Date
    Apr 2006
    Answers
    128

    How is it Evaluated?

    I want to know how *p++ gets evaluated as p being declared as a integer pointer. If anyone could explain the above with an example it would help me a lot.


  2. #2
    sammy is offline Senior Member Array
    Join Date
    Apr 2006
    Answers
    144
    In C programming both indirection operator and ++ operator takes the same level of precedence and the associativity is from right to left. So ++ gets evaluated first which means the address of p gets incremented and then the contents is retrieved from that and assigned to the variable. That is if you have address that is value of p as 1000 and contents of 1000 as 5. Then *p++ gets evaluated as 1000 gets incremented. Since it is integer it is incremented by 4 bytes which gives 1004 and contents of 1004 are accessed. This is how *p++ works.


Latest Article

Network Security Risk Assessment and Measurement

Read More...