Skip to content

Instantly share code, notes, and snippets.

@forestbelton
Created April 6, 2013 03:31
Show Gist options
  • Save forestbelton/5324631 to your computer and use it in GitHub Desktop.
Save forestbelton/5324631 to your computer and use it in GitHub Desktop.
generic swapping function in C
void gswap(void *v1, void *v2, size_t sz) {
char *c1 = v1;
char *c2 = v2;
char tmp;
while(sz--) {
tmp = *c1;
*c1++ = *c2;
*c2++ = tmp;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment