//This program is supposed to read 20 scores from an input file and initialize them to an array
//then print the components into 2 separate output files

#include <fstream>
#include <string>

using namespace std;


const int ARRAY_SIZE = 20; 
void printArray1(int scoresArray[], int sizeX);
void printArray2(int scoresArray[], int sizeY);

ofstream outFile1;
ofstream outFile2;

int main()
{
    int i; 
    int scoresArray[ARRAY_SIZE];

    ifstream inFile;


    inFile.open("scoresinput.txt");
    outFile1.open("scoresoutput1.txt");
    outFile2.open("scoresoutput2.txt");

    for (i=0; i<20; i++)
    inFile >> scoresArray[i];

    outFile1 << printArray1(scoresArray, 20) << endl;
    outFile2 << printArray2(scoresArray, 20) << endl;

    inFile.close();
    outFile1.close();
    outFile2.close();

    system ("pause");    
    return 0;
}     

void printArray1(int scoresArray[], int size1)
{
     int j; 
     outFile1 << "The first ten scores of this array are: "
              << endl;
     for (j=0; j<10; j++)
     outFile1 << scoresArray[j] << " " << endl;
}

void printArray2(int scoresArray[], int size2)
{
     int k;
     outFile2 << "The last ten scores of this array are: "
              << endl;
     for (k=10; k<20; k++)
     outFile2 << scoresArray[k] << " " << endl;
}

This program won't compile because of the error message:
31 C:\Users\james\Documents\quiz 1.cpp no match for 'operator<<' in 'outFile1 << printArray1(((int*)(&scoresArray)), 20)'
Any help would be greatly appreciated.
Thanks

Your printArray() functions don't return anything, so there will be no operator << associated with them. Remove the outfile << in main() from lines 32 and 33.

@ rubberman
Thanks a lot,
It works perfectly now after removing the outfile and endl
I'm not sure I perfectly understand your explanation though, if you can shed more light on it I'll greatly appreciate it. I'm new to programming so I try to understand every details as much as possible.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.