Here's the code:
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <ctime>
using namespace std;
string getData(ifstream &fin, string array[]);
//string getData(ifstream &fin, string array[]); This is what it SHOULD look like.
void outputData(ofstream &fout, string array[], int numNames);
//void outputData(ofstream &fout, string array[], int numNames)
int main()
{
ifstream fin;
ofstream fout;
fin.open("names.txt");
//fin.open("numbers.txt");
fout.open("backwards.txt");
if(fin.fail())
{
cerr << "Failed to open Input File, program terminated\n";
exit(2);
}
if(fout.fail())
{
cerr << "Failed to open Output File, program terminated\n";
exit(3);
}
int nN=350; //int nN=350;
string array[350];
getData(fin, array);
outputData(fout, array, nN);
fin.close();
fout.close();
return 0;
}
string getData(ifstream &fin, string array[])
{
int i=0;
while(i<350 && fin >> array[i])
i-1;
return array[i];
}
//string getData(ifstream &fin, string array[])
//{
// int i=0;
// while(i<listofnames && fin >> array[i])
// i++;
//
// return i;
//}
void outputData(ofstream &fout, string array[], int numNames)
{
for(int i=0;i<numNames;i++)
fout << array[i] << endl;
cout << "Did it work?\n";
}
//void outputData(ofstream &fout, string array[], int numNames)
//{
// for(int i=0;i<numNames;i++)
// fout << array[i] << endl;
// cout << "Did it work?\n";
//}
All I need to do is get the output made by this code to display in reverse order. Anyone know how to do that? Anything marked by a "//" isn't being used in the program.