title: How to find the number of occurrences of substring in a string?
body: <p>I wrote this C code that can find the number of occurrences of a substring in a string. The problem is it overlaps  meaning if I search for the letters pp in a string that has ppp the answer will be 2 occurrences instead of 1. I need help stopping this overlapping.</p>
  <pre><code>Description:
  • This command should search for the given substring in string and then
  return the number of occurrences of this substring if found or zero if not
  found.
  • &lt;string&gt; is sample statement
  • &lt;substring&gt; contains a character or more that we need to find the number
  of its occurrences in &lt;string&gt;
  Notes:
  • The given string contains multiple words separated by underscore; i.e. the
  underscore acts here exactly as if spaces exist between words
  • The substring is not necessary be exist in the given string and in this case
  return 0
  </code></pre>
  <p>The test cases it has to pass are:</p>
  <pre><code>hello_world➔ld ➔ 1 
  hello_world➔l ➔ 3 
  hello_world_o_w➔o_w ➔ 2 
  hellohellohellohello➔lo ➔ 4 
  operating_systems➔ss ➔ 0 
  defenselessness➔ss ➔ 2 
  ppppppp➔pp ➔ 3 
  </code></pre>
  <pre><code>char* fullString = arguments[1];
      char* subString = arguments[2];
      int fullLength=strlen(fullString);
      int subLength=strlen(subString);
      int result = 0;
  
      for(int i=0;i&lt;fullLength;i++){
          int check;
          for(check=0;check&lt;subLength;check++)
              if (fullString[i+check]!=subString[check])
                  break;
  
          if(check==subLength){
              result++;
              check=0;
          }
      }
      return result;
  </code></pre>