title: The problem of analyzing a string and searching
body: <p>I want to write code that takes a string of text from the user and shows the number of characters and the number of words using the .find () function.  then takes a word from user and Search the text and show the position of the word. I'm in trouble now, please help me.</p>
  <pre><code>#include&lt;iostream&gt;
  #include &lt;cctype&gt;
  #include&lt;string&gt;
  #include&lt;cstring&gt;
  using namespace std;
  
  int main()
  {   char quit;
      int word=0;
      string txt;
      cout &lt;&lt; &quot;Enter a string: &quot;;
      getline(cin, txt);
      cout &lt;&lt; &quot;The number of characters in the string is:&quot; &lt;&lt; txt.length() &lt;&lt; endl;
      while(string txt != NULL)
      {   if(txt.find(&quot; &quot;))
              ++word;
      }
      cout&lt;&lt;&quot;wors is &quot;&lt;&lt;word;
      while(quit!='q')
      {
  
          cout&lt;&lt;&quot;wors is &quot;;
          cin&gt;&gt;search;
          cout&lt;&lt;&quot;Enter(c)if you want to continue, and enter(q)if you want quic:&quot;;
          cin&gt;&gt;quit;
      }
      return 0;
  }
  </code></pre>