title: Finding words in sentences
body: <p>I have a programming assignment I cannot finish. This one part is killing me.</p>
  
  <blockquote>
    <p>Accept some text from the user. Accept the string that needs to be searched. Your program is supposed to print the number of occurrences of the string found within the text, and the position at which the pattern was found. Look at the following sample output:</p>
    
    <blockquote>
      <p>Sample Output:
      Enter text: “Call me Ishmael. Some years ago - never mind how long precisely - having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world. It is a way I have of driving off the spleen, and regulating the circulation”</p>
      
      <p>String to search – “Some years ago”</p>
      
      <p>Number of occurrences – 1</p>
      
      <p>Position Found – 18    </p>
    </blockquote>
  </blockquote>
  
  <p>This is my function:</p>
  
  <pre><code>void getText()
  {
      string itext, word;
      int position;
      bool done =  false;
      cout &lt;&lt; "Enter some text" &lt;&lt; endl;
      cin &gt;&gt; itext;
      cout &lt;&lt; "Enter the word or phrase to wish to find" &lt;&lt; endl;
      cin &gt;&gt; word;
      char text[itext.length()];
      char search[word.length()];
  
      for(int i = 0; i &lt; itext.length(); i++)
      {
          for(int j = 0; j &lt; word.length(); j++)
          {
              if(text[i] == search[j])
              {
                  position = i;
                  cout &lt;&lt; position;
              }
          } 
       }
  }
  </code></pre>