The easy solution is
#include <algorithm>
then simply std::swap the two pointers, ie std::swap(first, second).
The slightly harder solution is to write your own swap, and call it order.
void order(const char*& first, const char*& second) {
const char* temp = second;
second = first;
first = temp;
}
note the use of & in the arguments. This means that the arguments are passed by reference, which means that modifications to the pointers will be reflected in modifications to the passed in arguments.
References are a C++ feature that lets you make variables be aliases for other variables.
Your problem is that you confused the map (the pointer) for the territory (the data pointed to), then thought that = on the pointers modified the data. Instead, you made a copy of the maps (the pointers), drew all over them in your function, and then discarded the copies you made after you left your subprocedure.
Because all of the changes (the swapping) was on the copies of the pointers (the duplicate maps), the original pointers (the maps) where left alone.
I'm using "map" and "territory" as a reference to Alfred Korzybski, neither of these words are being used in a programming context, or refer to what is usually called map in C++.
constis not the problem.swap, as instd::swap. Second, you passed copies of the pointers into your function, then modified those pointers. Pointers are not the data pointed to, the map is not the territory.constapplies to thecharthat each pointer points to, not to the pointer itself.