I'm looking for print only Unique permutation. Function that should take one string as input and print out the unique permutations (without repeating) of that string in lexicographic (alphabetical) order.
this is what i have so far but when I run it gave me an error. I think my parameters in the printPermutations doesn't match the main function but I can't change the main function because it was given to test the code.
void printPermutations(string word, int currentIndex, int wordSize){
if(currentIndex == wordSize){
cout << word << endl;
return;
}
else{
for (int j = currentIndex; j = wordSize; j++){
swap(word[currentIndex], word[j]);
printPermutations(word, currentIndex +1, wordSize);
swap(word[currentIndex], word[j]);
}
}
}
int main(int argc, char* argv[]){
string word = "abcd";
printPermutations(argv[1]);
return 0;
}