title: I made a program, but can't seem to find the error, anyone has got a clue?
body: <pre><code>#include &lt;stdio.h&gt;
  
  int main() { //main function
      char string1[400] = &quot;Pinot noir is a red wine grape variety of the species Vitis vinifera. The name may also refer to wines created predominantly from Pinot noir grapes. The name is derived from the French words for pine and black. The word pine alludes to the grape variety having tightly clustered, pine cone-shaped bunches of fruit.[1].&quot;;
      char string2[400] = &quot;Metallica is an American heavy metal band. The band was formed in 1981 in Los Angeles by vocalist/guitarist James Hetfield and drummer Lars Ulrich, and has been based in San Francisco for most of its career.[1][2] The band's fast tempos, instrumentals and aggressive musicianship made them one of the founding big four bands of thrash metal, alongside Megadeth, Anthrax and Slayer.&quot;;
  
      char str[15]; //string declaration
      printf(&quot;Enter the word to be searched : &quot;);
      scanf_s(&quot;%s&quot;, str); //taking word from user
  
      int i, k = 0, length = 0, count1 = 0, count2 = 0; //declaring required variables
      for (i = 0; str[i] != '\0'; i++) { //calculate length of given word
          length++;
      }
  
      for (i = 0; string1[i] != '\0'; i++) { //loop through string1
          if (str[k] == string1[i]) { //if character of word equals to character of string1
              i++;
              if (k == length &amp;&amp; string1[i - length] == ' ' &amp;&amp; string1[i + 1] == ' ') { //checking spaces front and back of the word in string1
                  count1++; //incrementing count
                  k = 0;
              }
          } else {
              k = 0;
          }
      }
      for (i = 0; string2[i] != '\0'; i++) { //same logic as we found word in string1
          if (str[k] == string2[i]) {
              k++;
              if (k == length &amp;&amp; string1[i - length] == ' ' &amp;&amp; string1[i + 1] == ' ')      {
                  count2++;
                  k = 0;
              }
          } else {
              k = 0;
          }
      }
      printf(&quot;'%s' is found %d times in the String1.\n&quot;, str, count1); 
      //printing count in String1
      printf(&quot;'%s' is found %d times in the String2.&quot;, str, count2); 
      //printing count in String2
  }
  </code></pre>