Maui
Newbie
- Joined
- Jul 6, 2004
- Messages
- 390
- Reaction score
- 0
Hey guys, here's something that's had me frustrated for a while. It should be simple enough: I'm trying to organize a vector of c-strings that hold sentences using an insertion sort. All is well and good until I go to swap two pointers in the vector.
What I tried initially is
When I call that from somewhere else with swap(pA, pB) (where pA and pB are pointers to char arrays) it compiles okay but doesn't seem to actually swap them. All the google searches I did were for swapping numbers about, not even arrays of numbers - and of course "swap arrays" only returned results about swapping values *within* arrays.
Any help is appreciated :thumbs:
What I tried initially is
Code:
void swap(char *a, char *b)
{
char *t;
t = a;
a = b;
b = t;
}
When I call that from somewhere else with swap(pA, pB) (where pA and pB are pointers to char arrays) it compiles okay but doesn't seem to actually swap them. All the google searches I did were for swapping numbers about, not even arrays of numbers - and of course "swap arrays" only returned results about swapping values *within* arrays.
Any help is appreciated :thumbs: