I'm quite sure the manual looping can be avoided using std::next_permutation. Manual looping like this is terrible, especially when the Standard library foresees this kind of thing.
Here's some quick code:
#include
using std::next_permutation;
#include
using std::cout;
using std::endl;
#include
using std::string;
int main()
{
string currentPermutation = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
size_t i=0;
do
{
cout << "permutation " << i << ": " << currentPermutation << endl;
++i;
} while( next_permutation(currentPermutation.begin(), currentPermutation.end()) );
return 0;
}
This will permutate through all combinations of the string.