daktem21
June 30th, 2007, 02:07 PM
what it means?
*(ptr++) = x ??????
*(ptr++) = x ??????
|
Click to See Complete Forum and Search --> : ptr++[0] = x daktem21 June 30th, 2007, 02:07 PM what it means? *(ptr++) = x ?????? S_M_A June 30th, 2007, 02:37 PM Increment ptr then assign *ptr the value of x Zaccheus June 30th, 2007, 04:32 PM Yes, but it assigns x to the location that ptr was pointing to before ptr had been incremented. S_M_A June 30th, 2007, 04:47 PM Huh, shouldn't parenthesis make incrementation go first? MikeAThon June 30th, 2007, 06:31 PM Sorry, Zaccheus, I didn't realize that you were not the OP Yes, but it assigns x to the location that ptr was pointing to before ptr had been incremented. That's the way it's supposed to work. The value of a postfix expression is the value of the operand before the increment is applied. After the postfix expression is evaluated, the operand is incremented. The purpose of the parenthesis is to indicate that the postfix operator works on ptr, and not the value pointed-to by ptr. If you want to assign x to the location pointed-to by ptr after incrementation, then use a preincrement: *(++ptr) = x; Mike PS: Why is this a network question?? MikeAThon June 30th, 2007, 06:33 PM Increment ptr then assign *ptr the value of x Disagree. As explained above, the expression means that *ptr gets the value of x, and then ptr is incremented. Mike codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |