title: Recursive boolean function to check if a string is a palindrome
body: <blockquote>
    <p>Write a recursive boolean function that returns 1 if a string is a palindrome and 0 if not.</p>
  </blockquote>
  
  <pre><code>bool ispalindrome(char str[])
  </code></pre>
  
  <p><strong>Notes:</strong> the function must be recursive (not a wrapper for recursive function), it has to use the given (above) signature and no global or static variables are allowed, also, we can't 'destroy' the given string.</p>
  
  <p>My attempt:</p>
  
  <pre><code>bool ispalindrome(char str[]){
      bool res;
      if (*str == 0 || *(str + 1) == 0)
          return 1;
      else{
          res = ispalindrome(str + 1);
  </code></pre>
  
  <p>Now I'm stuck, I thought of making a helper function that uses dynamic arrays that would have the first and last elements from the original string removed and use that in the recursive call but I don't think that's the intended solution.</p>
  
  <p>EDIT: I've made some progress, but it doesn't work:</p>
  
  <pre><code>bool ispalindrome(char str[]){
      bool res;
      int l = strlen(str);
      char t;
      if (*str == 0 || *(str + 1) == 0)
          return 1;
      else{
          t = str[l-1];
          str[l-1] = 0;
          res = ispalindrome(str + 1);
          if (res == 0)
              return 0;
  
          if (str[0] == str[l - 2])
              res =1;
          else 
              res=0;
          str[l] = t;
          return res;
      }
  }
  </code></pre>