How to print permutations of string in lexicographical order?

Approach to solve this question.

Sort the string in increasing order … and then prints it permutations till all the characters are not in descending order

Just use the inbuilt functions:

#include <bits/stdc++.h> 
using namespace std;

int main(){
string s;
cin >> s;

sort(s.begin(), s.end());

while(next_permutation(s.begin(), s.end()))
      cout << s << endl;

return 0;
}