Okay I am SO new to C++ and I'm trying to write a code where the user can input the file name to read from. I have looked at a million forums but it doesn't seem to work for me. The program compiles but it is not getting the correct values from the file. This is a simplified version of what I have.
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
double span;
string inputfilename;
ifstream inputfile;
cout <<"Enter file name" <<endl;
cin>>inputfilename;
inputfile.open(inputfilename.c_str());
inputfile>>span;
cout<<span;
inputfile.close();
system("PAUSE");
return 0;
}