title: c++ Reading numbers from text files, ignoring comments
body: <p>So I've seen lots of solutions on this site and tutorials about reading in from a text file in C++, but have yet to figure out a solution to my problem. I'm new at C++ so I think I'm having trouble piecing together some of the documentation to make sense of it all. </p>
  
  <p>What I am trying to do is read a text file numbers while ignoring comments in the file that are denoted by "#". So an example file would look like:</p>
  
  <pre><code>#here is my comment
  20 30 40 50
  #this is my last comment
  60 70 80 90
  </code></pre>
  
  <p>My code can read numbers fine when there aren't any comments, but I don't understand parsing the stream well enough to ignore the comments. Its kind of a hack solution right now. </p>
  
  <pre><code>/////////////////////// Read the file ///////////////////////
  std::string line;
  if (input_file.is_open())
  {
      //While we can still read the file
      while (std::getline(input_file, line))
      {
          std::istringstream iss(line);
          float num; // The number in the line
  
          //while the iss is a number 
          while ((iss &gt;&gt; num))
          {
              //look at the number
          }
      }
  }
  
  else
  {
      std::cout &lt;&lt; "Unable to open file";
  }
  /////////////////////// done reading file /////////////////
  </code></pre>
  
  <p>Is there a way I can incorporate comment handling with this solution or do I need a different approach? Any advice would be great, thanks. </p>