title: Taking string objects using getline
body: <p>I am trying to take user input directly from console using getline into a C++ string object. I am however failing to do so as the compiler gives me the following error.</p>
  
  <pre><code>main.cpp: In function ‘int main(int, char**)’:
  main.cpp:52:28: error: no matching function for call to ‘std::basic_ifstream&lt;char&gt;::getline(std::ifstream&amp;, std::string&amp;)’
  main.cpp:52:28: note: candidates are:
  /usr/include/c++/4.6/istream:599:5: note: std::basic_istream&lt;_CharT, _Traits&gt;&amp; std::basic_istream&lt;_CharT, _Traits&gt;::getline(std::basic_istream&lt;_CharT, _Traits&gt;::char_type*, std::streamsize, std::basic_istream&lt;_CharT, _Traits&gt;::char_type) [with _CharT = char, _Traits = std::char_traits&lt;char&gt;, std::basic_istream&lt;_CharT, _Traits&gt;::char_type = char, std::streamsize = int]
  /usr/include/c++/4.6/istream:599:5: note:   candidate expects 3 arguments, 2 provided
  /usr/include/c++/4.6/istream:408:7: note: std::basic_istream&lt;_CharT, _Traits&gt;::__istream_type&amp; std::basic_istream&lt;_CharT, _Traits&gt;::getline(std::basic_istream&lt;_CharT, _Traits&gt;::char_type*, std::streamsize) [with _CharT = char, _Traits = std::char_traits&lt;char&gt;, std::basic_istream&lt;_CharT, _Traits&gt;::__istream_type = std::basic_istream&lt;char&gt;, std::basic_istream&lt;_CharT, _Traits&gt;::char_type = char, std::streamsize = int]
  /usr/include/c++/4.6/istream:408:7: note:   no known conversion for argument 2 from ‘std::string {aka std::basic_string&lt;char&gt;}’ to ‘int’
  </code></pre>
  
  <p>Here is the source code:</p>
  
  <pre><code>#include &lt;iostream&gt;
   #include &lt;fstream&gt;
   #include &lt;cmath&gt;
   #include &lt;cstdlib&gt;
   #include &lt;cstring&gt;
   #include &lt;string&gt;
   #include &lt;map&gt;
   #include &lt;set&gt;
   #include &lt;algorithm&gt;
   #include &lt;cstdio&gt;
  
   #define MAX_LIN 1024
  
   using namespace std;
  
   typedef set&lt;int&gt; si;
  int main(int argc, char** argv)
   {   
       string line1;
       string line2;
  
       map &lt;string , si &gt; iMap;
  
       if (argc != 3) { 
           fprintf(stderr,"Usage: a.out &lt;file1&gt; &lt;file2&gt;\n");
       }
  
       ifstream f1,f2;
  
       f1.open(argv[1],ifstream::in);
       f2.open(argv[2],ifstream::in);
  
       while(!f1.eof()) {
           getline(f1,line1);
           mParse(line1);
       }   
  
       while(!f2.eof()) {
           f2.getline(f2,line2);
           mParse(line2);
       }   
  
       f1.close();
       f2.close();
  
  
       return 0;
   }   
  </code></pre>