Find the frequency of "the" in the given sentence

Given a sentence of words, find the number of times the word "the" occurred in the sentence.



#include <stdio.h>
#include <string.h>
#include <stdlib.h>
int main(void) {
    
    /* Initialize the word "the", substring, the count of which is extracted from the main string s */
 char *s,*v="the";

   int slen,i,index,j,k,flag,count=0;
 
    /* Allocate memory for the input string */
  s=(char*)malloc(sizeof(s)*256);

    /* Get the input sentence from the user */
  gets(s);

    /* Calculate the length of the input sentence (number of characters except '\0'(null character)) */
  slen=strlen(s);

    /* Until we reach the end of the sentence */
  for(i=0;i<slen;i++)
   {
 
    /* Set the flag value to 1 */
   flag=1;

     /* Compare the first character occurence of the first character from the sub-string "the" in the sentence */
    if(*(s+i)==*v)
  {
      /* If the first character of both the sentence and teh sub-string matches */
      k=i;

         /* Until we reach the end of the sub-string "the" , check if all the characters of it matches with the characters of the sentence from that index */
      for(j=0;*(v+j);j++,k++)
      {

          /* If any of the character in the sub-string doesn't match the characters in the sentence , set the flag value as 0(zero) */
       if(*(s+k)!=*(v+j))
        {
          flag=0;
          break;

        }
      }
         /* If the flag value is not set , then there exists atleast one substring that matches in the main string */
      if(flag)
      {
           /* Increment the count of the sub-string occurence all the characters of sub-string matches a part of the sentence*/
       count++;
      }
     }
   }

    /* Print the count of the occurence of the word "the" in the sentence */
  printf("count of 'the' in %s is %d",s,count);

  return 0;

}