I am attempting to write a program for an assignment. I have to use several functions to open and then write some data to an external file. I have to use one function just to open the external file and then another function to write a header with columns to the file. It is a requirement that we allow the user to name the file. Here is my difficulty; I was able to allow the user to name the file and then open it, but it doesn't write the data to the file. Here is my code.
Can someone tell me what I am going wrong? I am pretty sure the problem is occurring because the file is being opened in one function and written to in another, but I have no idea how to get around it.
using namespace std;
int openOutputFile(char n);
double calculateMonthlyPayment(double r, double expm, double yrs);
double calculateTotalPayment(double mPmt);
cout << "Please type the name of the output file, including the extension: ";
cin >> outputName;
int openOutputFile(char name)
cerr << "Could not open " << name << "!" << endl;
outFile << "Loan Amount: $1000" << '\n';
outFile << left << setw(9) << "Interest" << left << setw(9) << "Duration" << left << setw(9) << "Monthly";
outFile << left << setw(9) << "Total" << '\n';
outFile << left << setw(9) << "rate" << left << setw(9) << "(years)" << left << setw(9) << "payment";
outFile << left << setw(9) << "payment" << '\n';