About the article

Swapping without a Buffer

-

Most programmers will have their own library of commonly used snippets of code. One task that appears very often is the exchange of the contents of two variables. The code for this usually looks as follows:

int c;

c=a;
a=b;
b=c;

There doesn't appear to be anything wrong with this, but it does make use of a third variable and this takes up more memory.
Downloading of this magazine article is reserved for Elektor Members only.
Already a member? click here to log in.
Loading comments...