My bit-wise swapping isn't working
<p>i am trying a simple insertion sort. But the swapping I am trying isn't working when I use bit-wise operation.</p>

<p>But when I use another temporary variable the swapping works. When I compile this code I always get some extra 0s.  </p>

<p>Can you help me to figure out what is wrong with my code?</p>

<pre><code>#include&lt;cstdio&gt;
#include&lt;cstdlib&gt;
#include&lt;algorithm&gt;
#include&lt;algorithm&gt;

using namespace std;

void swap(int* a, int* b)
{
*a=*a^*b;
*b=*a^*b;
*a=*a^*b;
}

int main(void)

{
int arr[size];
int i,j,min;

for(i=0; i&lt;size; i++)
    arr[i]=rand()%100;

for(i=0; i&lt;size; i++)
    printf("%d ",arr[i]);
putchar('\n');

for(i=0; i&lt;size;i++)
{
    min=i;
    for(j=i+1;j&lt;size;j++)
        if(arr[j]&lt;arr[min])
            min=j;
    swap(&amp;arr[i],&amp;arr[min]);
}

for(i=0; i&lt;size; i++)
    printf("%d ",arr[i]);
putchar('\n');

return 0;
}
</code></pre>
