title: Iterator to count the number of columns in csv using C++
body: <p>I am following the solution code by Loki Astari on </p>
  
  <p><a href="https://stackoverflow.com/questions/1120140/how-can-i-read-and-parse-csv-files-in-c?rq=1">How can I read and parse CSV files in C++?</a></p>
  
  <p>How can i write an iterator in the main function to count the number of columns from CSV header</p>
  
  <pre><code>int main()
  {
      std::ifstream       file("plop.csv");
  
      for(CSVIterator loop(file); loop != CSVIterator(); ++loop)
      {
          //Instead of printing the 4th element as shown below, I want to  print all the
          //columns and thus determine the number of columns
  
           //std::cout &lt;&lt; "4th Element(" &lt;&lt; (*loop)[3] &lt;&lt; ")\n";
  
  
      }
  }
  </code></pre>
  
  <p>Here is an example header of a csv file I am working with</p>
  
  <pre><code>cmd, id, addr, qos, len, lock, prot, burst, size, cache, user, duser, dstrb, data
  </code></pre>
  
  <p>I want to print them using an iterator or some for loop and determine the number of columns which in this case is 14</p>