title: Recursive strstr function
body: <blockquote>
    <p>Write the function <code>strstr</code> such that it would be a recursive function (not a wrapper for recursion) using the following signature. </p>
  </blockquote>
  
  <p>In short <code>strstr</code> returns the index of where the substr appears in str first and if it wasn't found it returns -1. More <a href="http://www.cplusplus.com/reference/cstring/strstr/" rel="nofollow">here</a></p>
  
  <p>This is my attempt:</p>
  
  <pre><code>int strstr1(char *str, char *substr){
  
      if (*str == 0 || *substr == 0)//basis, if any of the strings is empty, will return -1
          return -1;
      else{
          strstr1(str + 1, substr); //forward the address of str
          if (*str == *substr)    //for each level check if the first char matches, then it should match each pair
              strstr(str + 1, substr + 1);
  </code></pre>
  
  <p>But I got stuck. I realize there might be a need for backtracking in the recursion but I have no clue on how to do it, nor how to pass the index through all levels of recursion...</p>
  
  <p>Any hints or suggestions please?</p>