I am trying to compile the following code and I keep getting a reference error for my output file through a function. The purpose of the program is to read a file, sort through arrays, and output into a certain form. I am sure it is something small, but I do not understand what I am doing wrong. Thanks in advanced for any help.

#include <iostream>
#include <fstream>
#include <string>
#include <iomanip>

using namespace std;

const int runners = 5;
const int days = 7;

void readFile(ifstream& infile, string names[], double miles[runners][days]);
void fileOutput(ofstream& outfile, string names[], double miles[days], double 
     averageMiles[days]);
void calcMiles(string names[], double miles[][days], double averageMiles[days]);


main ()
{
    string names[runners];
    double day[runners][days];
    double milesDays[days];
    double average[runners];
    ifstream inputFile;
    ofstream outputFile;

        cout << "Runners Log" << endl;
    inputFile.open("data.txt");
    outputFile.open("newfile.txt");

    readFile(inputFile, names, day);
    calcMiles(names, day, average);
    fileOutput(outputFile, names, milesDays, average);

        inputFile.close();
        outputFile.close();

    return 0;
}

void readFile(ifstream& infile, string names[], double miles[][days])
{
        for(int i = 0; i < runners; i++)
     {
         infile >> names[i];
         for(int j = 0; j < days; j++)
         {
             infile >> miles[i][j];
         }
     } 
}
void fileOutput(ofstream& outfile, string names[], double miles[][days], double 
     averageMiles[days])
{
        double avg = 0;
    outfile << "Runners Log" << endl;
    outfile << "Results" << endl;
    outfile << setw(10) << "Name" << setw(10) << "Day 1" 
         << setw(10) << "Day 2" << setw(10) << "Day 3" <<  
         setw(10) << "Day 4" << setw(10) << "Day 5" << setw(15) << "Average Miles" << setw(10) << endl;

    for(int i = 0 ; i < runners; i++)
    {
        outfile << setw(10) << names[i];
        for(int j = 0; j < 7; j++)
        {
            outfile << setw(10) << miles[i][j];
        }       

        outfile << setw(15) << averageMiles[i] << setw(10) << miles[i] << endl;
    }

    // Calculate and display class average
    for(int i = 0; i < runners; i++)
        avg += averageMiles[i];
    avg /= runners;
    outfile << endl << "Runners Average: " << setprecision(2) << avg << endl;
}
void calcMiles(string names[], double miles[][days], double averageMiles[days])
{
    double average;
    for(int i = 0; i < runners; i++)
    {
        average = 0;
        for(int j = 0; j < days; j++)
        {
            average += miles[i][j];
        }
        average = (double)average/days;
        averageMiles[i] = average;
        }
}

Edited 1 Year Ago by Kenneth_3: spelling

Line 51, third parameter expects to be a double miles[][days] but you're trying to call a function on line 32 that expects a double milesDays[days]

Edited 1 Year Ago by Moschops

Thank you, I just kept overlooking that. Now when I run it all the data itself is correct but it is not showing up in rows/columns, it is just showing in a straight line. I do not know if it is simply my compiler (netbeans) or another simple fix.

Edited 1 Year Ago by Kenneth_3

Quick note on nomenclature; netbeans is not a compiler. The compiler is the software program that takes your text files containing source code, and turns them into a binary file, ready for your linker to smoosh together with other object files and turn into your executbale or library. Your IDE, netbeans, will be calling a compiler for you, and feeding it your source files. Depending on how you got your copy of netbeans, it may have come bundled with a compiler (MinGW is typical on windows, gcc on *nix) to save you having to find one yourself.

Anyway, if you show us what the output looks like, and say what you don't like about it, we can tell you how to change it.

Edited 1 Year Ago by Moschops

Sorry for the misuse of terms, I thought netbeans was a complier as well as an IDE, but I do believe I had to include something like you are talking about during install. I also use Cygwin and I know I had to download a seperate compiler for that. I tried to paste on here what my output looks like but it is shrinking it to this size window. It is simply outputting a single straight line instead of rows and columns.

This question has already been answered. Start a new discussion instead.