(a)
#define swap(x,y) {int tmp=y; y=x; x=tmp;}

(b)
swap(c.red, d->blue)

(c)
{ int tmp=d->blue; d->blue=c.red; c.red=tmp; }

(d)
swap(tmp, other)

(e)
{ int tmp=other; other=tmp; tmp=tmp; }

Example 1: swap.

Back to Article