------------------------------------------------------------------------------
MC logo
Increment Operators
[^] Code Examples
------------------------------------------------------------------------------
<<Average in C++ incr.c C++ Strings>>
#include <stdio.h>

int main() 
{
        int m = 10;
        int n = 5;

        m *= n - 3;
        printf("%d\n", m);

        n = ++m;
        printf("%d %d\n", n, m);

        n = m++;
        printf("%d %d\n", n, m);

        n = --m;
        printf("%d %d\n", ++n, m);

        n = m;
        m--;
        --n;
        printf("%d %d\n", n, m);
}

++x: Returns the new value of x.

x++: Returns the old value of x.

There is only a difference when the return value is used:
x++; and ++x; are the same.

Increment operators are similar to Java.
Things like x + ++x are not well-defined in C.
In the context of C, increments are better able to create bizarre programs.

Reading: pp. 71-74
<<Average in C++ C++ Strings>>