Here is a standard function to print the permutations of characters of a string:
void permute(char *a, int i, int n) { int j; if (i == n) printf(\
You can use std::set to ensure uniqueness of the results. That is if it is C++ (because you tagged it as such).
std::set
Otherwise - go through the list of the results manually and remove duplicates.
You'll have to save the results and post-process them of course, not print immediately as you do now.