Generates all possible permutations in the given string and substrings within.
C++ code that generates all possible permutations of the given string and substrings within.