title: In C find position of substring in a string
body: <p>Here is a program to accept a: </p>
  
  <ol>
  <li>Sentence from a user.</li>
  <li>Word from a user.</li>
  </ol>
  
  <p>How do I find the position of the word entered in the sentence?</p>
  
  <pre><code>#include &lt;stdio.h&gt;
  #include &lt;stdlib.h&gt;
  #include &lt;string.h&gt;
  int main()
  {
      char sntnc[50], word[50], *ptr[50];
      int pos;
      puts("\nEnter a sentence");
      gets(sntnc);
      fflush(stdin);
      puts("\nEnter a word");
      gets(word);
      fflush(stdin);
      ptr=strstr(sntnc,word);
  
      //how do I find out at what position the word occurs in the sentence?
  
      //Following is the required output
      printf("The word starts at position #%d", pos);
      return 0;
  }
  </code></pre>