Jul 4, 2011 at 5:00pm
You need to pass the pointers by reference, otherwise you'd only be changing them inside the function.
void swap(char *&a, char *&b)
http://www.cplusplus.com/doc/tutorial/functions2/
Also, you need to have those as
const char *
because they point to constant characters (string literals)
Last edited on Jul 4, 2011 at 5:01pm
Jul 4, 2011 at 5:06pm
Thank's, I thought that pass by reference was only used with "regular" variables.
Jul 4, 2011 at 5:09pm
Pointers are 'regular' variables. In fact, I can't really think of any variables or classes that aren't 'regular'.