Jump to content United States-English
HP.com Home Products and Services Support and Drivers Solutions How to Buy
» Contact HP
More options
HP.com home
HP C/HP-UX Reference Manual: Workstations and Servers > Chapter 5 Expressions

Prefix Increment and Decrement Operators

» 

Technical documentation

Complete book in PDF
» Feedback
Content starts here

 » Table of Contents

 » Index

The prefix increment or decrement operator increments or decrements its operand before using its value.

Syntax

++ unary-expression
-- unary-expression

Description

The operand for the prefix increment ++ or the prefix decrement -- operator must be a modifiable lvalue with scalar type. The result is not an lvalue.

The operand of the prefix increment operator is incremented by 1. The resulting value is the result of the unary-expression.

The prefix decrement operator behaves the same way as the prefix increment operator except that a value of one is subtracted from the operand.

For any expression E, the unary expressions ++E and (E+=1) yield the same result. If the value of X is 2, after the expression A=++X is evaluated, A is 3 and X is 3.

Pointers are assumed to point into arrays. Incrementing (or decrementing) a pointer causes the pointer to point to the next (or previous) element. This means, for example, that incrementing a pointer to a structure causes the pointer to point to the next structure, not the next byte within the structure. (Refer also to "Additive Operators" for information on adding to pointers.)

Printable version
Privacy statement Using this site means you accept its terms Feedback to webmaster
© 1996 Hewlett-Packard Development Company, L.P.