the arguments to your swap function become local variables so the swapping doesn't affect the callers pointers. your swap should look like swap(void **a,void **b); pass in the address of the pointers...