Opening a file using a variable name
<p>If I change myfile("input.txt") to myfile(file_name)...where file_name is passed to the function it does not work but gives the error no matching function call..which I'm guessing b.c. I'm not suppose to be passing a string to the constructor...if not this way..how?</p>

<pre><code>void file_to_string(string file_name)
{
   string line;  
   ifstream myfile("input.txt");
   if(myfile.is_open())
   {
      while(myfile.good())
      {
         getline(myfile,line);
         cout &lt;&lt; line;
      }
      myfile.close();
  }
  else
  {
      cout &lt;&lt; "File : " &lt;&lt; file_name &lt;&lt; " : did not open" ;
  }

}

int main(int argc, char *argv[])
{
    file_to_string(argv[1]);
}
</code></pre>
