On Wed, Feb 17, 2010 at 12:21 PM, sweet_heart _625
<[email protected]> wrote:
> The best way of swaping is

This has to be one of the worst ways of swapping.

> swap(int a,int b)
> {
>    a=a+b;
>    b=a-b;
>    a=a-b;
> }

No it isn't.
1) It may fail with overflow errors
2) Calling this in a program WON'T ACTUALLY SWAP ANYTHING the calling
code wants it to.

Read <http://tech.groups.yahoo.com/group/c-prog/files/html/swapnotemp.html>
(or <http://avsharath.googlepages.com/swapnotemp.html> if you can't
get the first copy) LIKE YOU WERE TOLD TO DO AT THE TOP OF THE THREAD!

-- 
PJH

http://shabbleland.myminicity.com/env
http://www.chavgangs.com/register.php?referer=9375

Reply via email to