title: Avoid reading punctuation from a file in C++
body: <p>I'm trying to find the longest word on a file in c++. I have the solution for that but the code is also considering the punctuation and I don't know how to avoid this.</p>
  <p>This is the function &quot;get_the_longest_word()&quot;:</p>
  <pre><code>string get_the_longest_word(const string &amp;file_name){
  int max=0;
  string s,longest_word;
  ifstream inputFile(file_name);
  
  if(inputFile.is_open())
  {
      while(inputFile&gt;&gt;s)
      {
          if(s.length()&gt;max)
          {
              max=s.length();
              s.swap(longest_word);
          }
      }
      inputFile.close();
  }else
      cout&lt;&lt;&quot;Error while opening the file!!\n&quot;;
  
  return longest_word;}
  </code></pre>
  <p>Thanks in advance for the help</p>