i am trying to read/write to/from two separate files, my code works as long as i execute it from the Visual C++ platform. when i double click on the exe file in the debug folder it doesn't write to the specified file. i think it has to do with the path names. my question is how to i define the path name completely? as in "H:\C2plus\monte_carlo\results.txt" ?
the portion of my code is as follows:
Code:
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <fstream>
#include <time.h>
using namespace std;
const char * filei="simMC1.txt";
const char * fileo="resultsMC.txt";
int N,call_put;
double X, TP, T, t1, z, r, So, Pavg, volatility;
double randaud();
int main ()
{
//read in file (call_put,N,TP,So,X,r,volatility)
ifstream infile(filei,ios::in);
ofstream outfile(fileo,ios: : out);
if(! infile.is_open())
{
cout << "error";
exit(1);
}
....
outfile << Pavg << endl;
return 0;
}
any help would be great!