title: Check if a string is the substring of another string
body: <p>I was having some problem when trying to check if a string is the substring of another string. Here is the expected output:</p>
  
  <pre><code>Enter a source string: abc
  Enter the target string: abcde
  findSubstring(): 1
  
  Enter a source string: abcde
  Enter the target string: cdef
  findSubstring(): -1 
  </code></pre>
  
  <p>And here is my code which used the strstr standard string library:</p>
  
  <pre><code>int main()
  {
      char sourceStr[40], targetStr[40];
  
      printf("Enter a source string: ");
      gets(sourceStr);
      printf("Enter the target string: ");
      gets(targetStr);
      printf("findSubstring(): %d\n", findSubstring(sourceStr, targetStr));
      return 0;
  }
  
  int findSubstring(char *s, char *t) {
      if (strstr(s, t) != NULL) {
          return 1;
      }
      return 0;
  }
  </code></pre>
  
  <p>With these code, it works perfectly. However, I was told that I am not supposed to use any standard string library, so I was thinking how should I modify it?</p>
  
  <p>Sorry for posting the question with no error but I seriously need a head start, as I googled for quite a while and I still have no idea how to do it.</p>
  
  <p>Thanks in advance.</p>