title: Differentiate between same strings with different punctuation in C++
body: <p>I am writing a C++ program to count the frequency of a word occurring in a text file. I am using the <code>isalpha</code> function to separate the words, but <code>isalpha</code> does not differentiate between same strings having different punctuation.</p>
  
  <p>For example: "I own a company. In my company, there are 200 employees. I love my company."
  In the above sentence it gives count of company as 3
  How do I make it to differentiate the count like:</p>
  
  <pre><code>company 1
  company, 1
  company. 1
  </code></pre>
  
  <p>The loop which does the counting:</p>
  
  <pre><code>while(!isalpha(c) &amp;&amp; !in.eof())
  {
      c = in.get();
  }
  
  while(isalpha(c))
  {
      out.push_back(tolower(c));
      c = in.get();
  }
  </code></pre>
  
  <p>where 'out' is a string, 'in' is an istream value and c is a char.</p>
  
  <p>[EDIT] Got Solution</p>
  
  <pre><code>while(!isalpha(c) &amp;&amp; !ispunct(c) !in.eof())
  {
      c = in.get();
  }
  
  while(isalpha(c) || ispunct(c))
  {
      out.push_back(tolower(c));
      c = in.get();
  }
  </code></pre>