Swapping without a Buffer
-
Published in issue 345, July 2005
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.
|
Click below to download a PDF copy of this article from Elektor magazine.
Please note. In view of the complexity of international markets, Elektor cannot guarantee the availability of components for this project.
|