Skip to content

Instantly share code, notes, and snippets.

@javiertoledo
Created October 24, 2010 00:26
Show Gist options
  • Save javiertoledo/642885 to your computer and use it in GitHub Desktop.
Save javiertoledo/642885 to your computer and use it in GitHub Desktop.
Classic variable swap in C
/*Initializations*/
int a,b,temp;
a=1;
b=2;
/*The classic swap code*/
temp=a;
a=b;
b=temp;
/*Values have been happily swapped! (a==2 && b==1)*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment