- Joined
- Feb 13, 2009
- Messages
- 1
- Reaction score
- 0
Hi I am trying to create a function that can read a file after i pass the filename but I having trouble doing so. Can anyone please tell me where I am going wrong with this thanks. My code is below
AvgimpliedVolatility is my function's name.
double AvgImpliedVolatility (const string& filename, char optiontype, double Time, double Interest_rate, double OptionSpotPrice)
{
ifstream myfile(filename);
if(myfile.is_open())
{
while (!myfile.eof() )
{
//read data file
getline (myfile,line);
cout << line << endl;
............
when i replace filename with the exact name of the file for example:"sp500.csv" the code works fine.
Please advise. I will be reading different file which is the reason I am trying to create that function.
Thanks
AvgimpliedVolatility is my function's name.
double AvgImpliedVolatility (const string& filename, char optiontype, double Time, double Interest_rate, double OptionSpotPrice)
{
ifstream myfile(filename);
if(myfile.is_open())
{
while (!myfile.eof() )
{
//read data file
getline (myfile,line);
cout << line << endl;
............
when i replace filename with the exact name of the file for example:"sp500.csv" the code works fine.
Please advise. I will be reading different file which is the reason I am trying to create that function.
Thanks