You can always use the following.
Void Swap(Void *A, void *B)
{
Void *Temp
Temp = A
A = B
B = temp
};
In this way, any varible type can be used. You
would have to pass the pointer to it, however.
This should be the best way possible.
--- On Thu, 2/18/10, Prince Annan Koomson <[email protected]> wrote:
From: Prince Annan Koomson <[email protected]>
Subject: Re: [c-prog] swap two numbers
To: [email protected]
Date: Thursday, February 18, 2010, 1:30 AM
Prince Annan Koomson
--- On Tue, 2/16/10, Paul Herring <pauljherring@ gmail.com> wrote:
On Tue, Feb 16, 2010 at 9:44 AM, Prince Annan Koomson
<pk_an...@yahoo. com> wrote:
> The best way in swaping is using pointers
--> No it isn't, it's to use a temporary variable.
> that helps you more better than doing the normal swaping.
--> and no it doesn't. You didn't read the article mentioned did you?
Correction please using pointers from my point of view is -->the code you
wrote and posted online e.g.swap(*x , *y){bla bla}
there is no way you can do swapping without declaring a temporary variable did
you listen to your self well?what i mean was doing normal swapping likeswap
(int x, int y){int temp;temp = y;y=x;x=temp; }
This normally does not work,But using pointers works perfectly that is what i
mean, there is no mistake in my post sorry.
[Non-text portions of this message have been removed]
[Non-text portions of this message have been removed]