Joined: Sun May 25, 2008 5:34 pm Posts: 95 Has thanked: 2 time Have thanks: 1 time
Code:
#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.