I have a test file ("InputFile.txt") saved with some random information as well as a blank output file ("output.txt"). When I debug the program and check the output file, it's still blank.
Should "output.out" be "output.txt" (line 25)? Am I having problems because I have "InputFile.txt" as a cstring at line 22 in the if statement? Is this correct otherwise? I'm sort of lost when it comes to fstream so far, please help.
My code:
#include<fstream>
#include<string>
#include<iomanip>
#include<iostream>
using namespace std;
int main()
{
    ifstream InputFile;
    ofstream OutputFile;
    string lastName, firstName, fileName,
        line;
    int creditHours, state;
    int tuition;
    bool valid = false;
    do{
    cout << "Input file name (.txt): ";
    cin >> fileName;
    if(fileName == "InputFile.txt")
    {
        InputFile.open("InputFile.txt");
        OutputFile.open("output.out");
        valid = true;
    }
    else{
        cout << "Invalid file name/type." << endl;
    }
    }while(valid == false);
    OutputFile << "Last Name: " << '   ' << "First Name: " << '   '
        << "Credit Hours: " << '   ' << "Tuition Amount: " << endl;
    while(!InputFile.eof()){
    getline(cin, line);
    InputFile >> firstName >> lastName >> creditHours >> state;
    if(state == 1)
    {
        tuition = (creditHours * 350);
    }
    else
    {
        tuition = (creditHours * 570);
    }
    OutputFile << lastName << '   ' << firstName << '   ' 
        << creditHours << '   ' << tuition << endl;
    }
    InputFile.close();
    OutputFile.close();
    return 0;
}
 
    