Recursively stripping a sentence, and checking for palindrome.

I am a student going to college for Computer Science, that being said I am very much a beginner. Our professor assigned us a problem that requires us to "strip" a user input of all upper case letters and spaces, for example if a user inputs "Hello World" the output would be "helloworld". They also asked us to check if a user input is a palindrome or not, and they wanted us to do all of this recursively. Below are two small c++ files for that strip and check for a palindrome, as well as a larger file that we have been instructed not to modify at all that I assume calls the other two files.

"Srip" code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
 // The functions is_upper(), is_lower(), is_alpha(), and to_lower()
// are provided for your convenience. Use them freely.

#include <string>
#pragma once

bool is_upper(char ch) { return ('A' <= ch) and (ch <= 'Z'); }

bool is_lower(char ch) { return ('a' <= ch) and (ch <= 'z'); }

bool is_alpha(char ch) { return is_upper(ch) or is_lower(ch); }

char to_lower(char ch)
{
  if (not is_upper(ch)) { return ch; }
  else
  {
    ch = static_cast<char>(ch + 'a' - 'A');
    // 'a' - 'A' gives the offset in ASCII value between any capital
    // letter and any lowercase letter; think of it as "final minus initial"
    return ch;
  }
}

std::string strip(std::string st)
{
  
  return st; // fill in your own recursive definition
}


Palindrome code:
1
2
3
4
5
6
7
8
#include <string>
#include "strip.cpp"
#pragma once

bool is_palindrome(std::string st)
{
  return false; // fill in your own *recursive* definition
}


Larger "untouchable" file:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
// This program only calls the other functions written by you.
// It allows you to test their output.
// Do not modify it in any way.
// Compile this file only: $ gg -o driver driver.cpp
// The #include directives will include your definitions
// appropriately.

#include <iostream>      // std::cin, std::getline(), std::cout, std::endl;
#include <string>        // std::string
#include <cstring>       // strcmp()
#include "strip.cpp" // test_strip()
#include "pal.cpp"   // test_is_palindrome()

void display_usage()
{
  using std::cout;
  using std::endl;
  cout << "Usage: driver strip [sentence]" << endl;
  cout << "   or: driver pal [sentence]" << endl;
  cout << "The [sentence] argument is optional, but you" << endl;
  cout << "will be prompted for it if you omit it." << endl;
  return;
}

std::string get_sentence(int argc, char *argv[])
{
  std::string result;
  if (argc == 2)
  {
    std::cout << "Enter a sentence: ";
    std::getline(std::cin, result);
  }
  else
  {
    for (int i = 2; i < argc - 1; ++i) // argc is an int, not a size_t
    {
      result += argv[i];
      result += " ";
    }
    result += argv[argc - 1];
  }
  return result;
}

int main(int argc, char *argv[])
{
  if (argc == 1 or (strcmp(argv[1], "strip") != 0 and strcmp(argv[1], "pal") != 0))
  {
    display_usage();
  }
  else
  {
    std::string sentence = get_sentence(argc, argv);
    if (strcmp(argv[1], "strip") == 0)
    {
      std::cout << "You entered    : " << sentence << std::endl;
      std::cout << "After stripping: " << strip(sentence) << std::endl;
    }
    else if (strcmp(argv[1], "pal") == 0)
    {
      std::cout << "You entered: \"" << sentence;
      std::cout << "\", which ";
      std::string is_not = (is_palindrome(sentence)) ? "is" : "is not";
      std::cout << is_not;
      std::cout << " a palindrome." << std::endl;
    }
  }
  return 0;
}
What is your question?

We're not going to write your assignment for you. You don't learn that way.
We will answer questions if you get stuck.
I absolutely agree, I've done some simple recursion and figured out how to check for a palindrome. I just don't know how to put those things together. I'm not asking you to write the entire program, if you have some advice on how I should start it that would be amazing. Me and my peers have tried bouncing things off of each other but have made basically no progress. If you have some advice that would be awesome if you could help me, but understand if you think it's wrong to help me on an assignment.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function is_palindrome:
    input: string str
    result: bool

    If the size of the string str < 2 return true
    Else
      If the first character of str != last character of str return false
      Else
          remove the first character of str
          remove the last character of str
          return is_palindrome(str)


function strip:
    input: string str
    result: string

    If str is empty return str
    Else
       let char c <- the last character of str
       remove the last character of str
       If c is an upper case letter or a space
           return strip(str)
       Else return strip(str) + c


Spoiler: http://coliru.stacked-crooked.com/a/43357e3d6e6f3b1f
Thanks for the help, I truly want to understand c++, just get confused easily and need help finding the right paths to take.
Topic archived. No new replies allowed.