DZone 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

Snippets has posted 5883 posts at DZone. View Full User Profile

Pointer Swap Function

04.23.2008
| 13511 views |
  • submit to reddit
        // A generic pointer swap function that works with all structs by calling swap(&A, &B), where A and B are struct pointers

void swap(void **x, void **y) {
	void *t = *x;
	*x = *y;
	*y = t;
}