title: C++ type of argument to ifstream::open()
body: <p>What type must I make my file name to use it as an argument to <code>ifstream.open()</code>?</p>
  
  <pre><code>int main(int argc, char *argv[]) {
      string x,y,file;
  
      string file = argv[1];
      ifstream in;
      in.open(file);
      in &gt;&gt; x;
      in &gt;&gt; y;
      ...
  </code></pre>
  
  <p>With this code, I get the following error: </p>
  
  <pre><code>main.cpp|20|error: no matching function for call to 'std::basic_ifstream&lt;char,
       std::char_traits&lt;char&gt; &gt;::open(std::string&amp;)'|
  gcc\mingw32\4.4.1\include\c++\fstream|525|note: candidates are: void std::basic_ifstream&lt;_CharT,
       _Traits&gt;::open(const char*, std::_Ios_Openmode) [with _CharT = char, _Traits = std::char_traits&lt;char&gt;]|
  </code></pre>
  
  <p>UPDATE:</p>
  
  <p>i get this error
  <img src="https://i.stack.imgur.com/8b0jZ.png" alt="enter image description here"></p>