Mapped strings problem

how to solve mapped strings problem

You can solve this problem recursively

foo(string s, int length, int index, int outputString) {
if(index == length) {
        cout << outputString << endl;
        return;
}

// Include only a single digit i.e. map digit at this index
if(index < length) {
         char x = map(s[index] - '0');
         foo(s, length, index + 1, outputString + x);
}

//Include two digits i.e. map the number formed by joining digit at current index and index + 1
if(index < length - 1 && NextTwoDigits < 26) {
          char x = map(NextTwoDigits);
          foo(s, length, index + 2, outputString + x);
}

}

Here length is the length of the input string
index denotes the location in the input string upto which the input string has been processed
outputString is the string which will be printed once the whole input string is processed