Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Turbo C - <b>-- decrement operator (prefix and postfix)</b> http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
--                       Decrement Operator (prefix and postfix)

 value--                 postfix decrement
 --value                 prefix decrement
   value                 any variable of type int, float, char, enum,
                           or related type

    The unary postfix operator -- decrements (subtracts one from ) lvalue
    after the expression containing lvalue has been evaluated. For
    example:

             j = 10; i = 5 * j--; /* i == 50, j == 9 */

    The unary prefix operator -- decrements lvalue before the expression
    containing lvalue has been evaluated. For example:

             j = 10; i = 5 * --j;  /* i == 45, j == 9 */

       Note:    In the case of pointers, -- moves the pointer to the
                previous element.  For example, if ptr is a pointer to a
                4-byte long, ptr-- actually subtracts 4 from ptr, thereby
                aiming it at the previous 4-byte long, not at the
                previous byte.  Decrementing a pointer to char always
                subtracts 1, on any machine.

                For pointers, both *(--lvalue) and lvalue[-1] fetch the
                same element. (We're not suggesting that you actually use
                a negative index.  Caveat Emptor.)

See Also: ++

Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson