C 后缀增量和减量运算符C Postfix Increment and Decrement Operators

后缀递增和递减运算符的操作数是可修改的左值的标量类型。Operands of the postfix increment and decrement operators are scalar types that are modifiable l-values.


postfix-expression ++postfix-expression ++

postfix-expression --postfix-expression --

后缀递增或递减运算的结果是操作数的值。The result of the postfix increment or decrement operation is the value of the operand. 获取结果后,操作数的值将增加(或减少)。After the result is obtained, the value of the operand is incremented (or decremented). 以下代码演示了后缀递增运算符。The following code illustrates the postfix increment operator.

if( var++ > 0 )  
    *p++ = *q++;  

在本示例中,变量 var 先与 0 进行比较,然后增加。In this example, the variable var is compared to 0, then incremented. 如果 var 在增加之前为正数,则执行下一条语句。If var was positive before being incremented, the next statement is executed. 首先,q 所指向的对象的值赋给 p所指向的对象。First, the value of the object pointed to by q is assigned to the object pointed to by p. 然后,qp 增加。Then, q and p are incremented.

另请参阅See Also

后缀增量和减量运算符:++ 和 --Postfix Increment and Decrement Operators: ++ and --