Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

nevada

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

swap values without temporary variable

The XOR swap algorithm is an inefficient method of swapping two variables. http://en.wikipedia.org/wiki/Xor_swap_algorithm

void XORSwap(void *x, void *y)
{
   *x ^= *y;
   *y ^= *x;
   *x ^= *y;
}
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS