title: How to open file based on user input?
body: <p>This code keeps giving me errors i dont know what Im doing wrong? 
  How can I request the user to input the filename and then open that file and perform
  tasks with the data.</p>
  
  <p>Example:    </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;fstream&gt;
  #include &lt;string&gt;
  
  using namespace std;
  
  int main ()
  { 
  ifstream inData;
  ofstream outData;
  string fileName;
  
  cout &lt;&lt; "Enter the data file Name : " &lt;&lt; endl;//asks user to input filename
  cin &gt;&gt; fileName; //inputs user input into fileName
  
  inData.open(fileName); //heres where i try to open the file with the users input?
  outData.open(fileName);
  cout &lt;&lt; fileName;
  return 0;   
  } 
  </code></pre>
  
  <p>The code keeps giving me errors. I have tried to use getline? I want the fileName to be string 
  and not char.   </p>