logo CodeStepByStep logo

lettersOnly

Language/Type: C++ recursion string return
Related Links:

Write a recursive function named lettersOnly that accepts a string s as a parameter and returns a string with the same characters as s, in the same order, but excluding any characters that are not alphabetic letters from A-Z, case-insensitive. For example, the call of lettersOnly("{[[Friends, save $$$ with 'Geico'!!]]}") should return "FriendssavewithGeico". If the string passed is empty or contains no letters, return an empty string.

  • Do not use any loops; you must use recursion.
  • Do not call any of the following string member functions: find, rfind, indexOf, contains, replace, split. (The point of this problem is to solve it recursively; do not use a library function to get around recursion.)
  • Do not use any auxiliary data structures like vector, map, set, array, etc.
Function: Write a C++ function as described, not a complete program.

You must log in before you can solve this problem.

Log In

Need help?

Stuck on an exercise? Contact your TA or instructor.

If something seems wrong with our site, please

Is there a problem? Contact us.