title: Why should I use c_str() in functions
body: <p>I am reading the book C++ Primer and at the file input output chapter it uses:</p>
  
  <pre><code>ifstream infile(ifile.c_str());
  </code></pre>
  
  <p>to open a file whose name is in the string <code>ifile</code>.</p>
  
  <p><strong>I tried the code and it works perfectly even without <code>c_str()</code>.</strong> So what is the point of using it?</p>
  
  <p><strong>Should I use <code>c_str()</code> when I am trying to open a file from a command line argument?</strong> I mean which is the correct usage:</p>
  
  <pre><code>ifstream fin( argv[1] )
  </code></pre>
  
  <p>or </p>
  
  <pre><code>ifstream fin( argv[1].c_str() )
  </code></pre>