//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;
}
eogunlolu 0 Newbie Poster
eogunlolu 0 Newbie Poster
rubberman 1,355 Nearly a Posting Virtuoso Featured Poster
eogunlolu 0 Newbie Poster
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.