Hi all,

Can someone please explain why the following short code works in a forward way, but not in reverse order?
For example: if 1234 is entered, the program generates and prints out correct number permutations, but if 4321 is entered it only prints one permutation, as 4321, why??
The same goes for abcd - dcba.
Thanks for any help and enlightenment. Compiler Dev-C++

//permutation
#include <iostream>
#include <algorithm>
#include <stdlib.h>

using namespace std;

int main()
{
char v[] = {0};
cout << "Enter a string: ";
cin >> v;
unsigned slen, len = strlen(v);
unsigned c = 1;

for(slen = 1; slen <= len; slen++)
{
c *= slen;
}
cout << v << '\t';
while(next_permutation(v, v+len))
{
cout << v << '\t';
}
cout << endl << "\nTotal of perms = " << c << endl << endl;

system("PAUSE");
return 0;
}