Skip to content

Instantly share code, notes, and snippets.

@javiertoledo
Created October 24, 2010 00:31
Show Gist options
  • Save javiertoledo/642894 to your computer and use it in GitHub Desktop.
Save javiertoledo/642894 to your computer and use it in GitHub Desktop.
Swap variable values without temp variables
/*Initializations*/
int a,b;
a=1;
b=2;
/*The swap code*/
a^=b^=a^=b;
/*That's all! Your variables swapped magically*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment