I am finding all possible permutations and comparing each with the original string ,if greater I print it, what is the fault in this code.
#include
#include
using namespace std;
void permute(char *in, int i, string str)
{
if (in[i] == ‘\0’)
{
if (in > str)
{
cout << in << endl;
}
return;
}
// Rec case
for (int j = i; in[j] != ‘\0’; j++)
{
swap(in[i], in[j]);
permute(in, i + 1, str);
swap(in[j], in[i]);
}
}
int main()
{
char in[100];
cin >> in;
string str;
str = in;
permute(in, 0, str);
return 0;
}