title: Formatting CSV files in C++
body: <p>I am trying to take a simple CSV file, split it line-by-line, and print it to the console. Currently I am getting an error when compiling and want to know if I am missing something obvious.</p>
  
  <pre><code>#include &lt;fstream&gt;
  #include &lt;iostream&gt;
  #include &lt;sstream&gt;
  #include &lt;string&gt;
  
  int main(int argc , char** argv) {
  
      std::string line;
      std::ifstream infile(argv[1]);
  
      if (infile) {
  
          while (getline(infile, line)) {
  
              std::istringstream ss(line);
              std::string token;
  
              while(std::getline(ss, token, ",")) {
  
                  std::cout &lt;&lt; token &lt;&lt; "\n";
  
              }
  
          }
  
      }
  
      infile.close();
      return 0;
  
  }
  </code></pre>
  
  <p>The error I am getting is as follows.</p>
  
  <pre><code>csv.cpp: In function 'int main(int, char**)':
  csv.cpp:41:46: error: no matching function for call to 'getline(std::istringstream&amp;,
  std::string&amp;, const char [2])'
  csv.cpp:41:46: note: candidates are:
  In file included from /usr/include/c++/4.7/string:55:0,
               from /usr/include/c++/4.7/bits/locale_classes.h:42,
               from /usr/include/c++/4.7/bits/ios_base.h:43,
               from /usr/include/c++/4.7/ios:43,
               from /usr/include/c++/4.7/istream:40,
               from /usr/include/c++/4.7/fstream:40,
               from csv.cpp:21:
  /usr/include/c++/4.7/bits/basic_string.tcc:1070:5: note: template&lt;class _CharT, class _Traits, class _Alloc&gt; std::basic_istream&lt;_CharT, _Traits&gt;&amp; std::getline(std::basic_istream&lt;_CharT, _Traits&gt;&amp;, std::basic_string&lt;_CharT, _Traits, _Alloc&gt;&amp;, _CharT)
  /usr/include/c++/4.7/bits/basic_string.tcc:1070:5: note:   template argument deduction/substitution failed:
  csv.cpp:41:46: note:   deduced conflicting types for parameter '_CharT' ('char' and 'const char*')
  In file included from /usr/include/c++/4.7/string:54:0,
               from /usr/include/c++/4.7/bits/locale_classes.h:42,
               from /usr/include/c++/4.7/bits/ios_base.h:43,
               from /usr/include/c++/4.7/ios:43,
               from /usr/include/c++/4.7/istream:40,
               from /usr/include/c++/4.7/fstream:40,
               from csv.cpp:21:
  /usr/include/c++/4.7/bits/basic_string.h:2792:5: note: template&lt;class _CharT, class _Traits, class _Alloc&gt; std::basic_istream&lt;_CharT, _Traits&gt;&amp; std::getline(std::basic_istream&lt;_CharT, _Traits&gt;&amp;, std::basic_string&lt;_CharT, _Traits, _Alloc&gt;&amp;)
  /usr/include/c++/4.7/bits/basic_string.h:2792:5: note:   template argument deduction/substitution failed:
  csv.cpp:41:46: note:   candidate expects 2 arguments, 3 provided
  </code></pre>