I'm trying to write a program that takes numbers from a text file and then sorts them first by name and then by the average. When I go to compile I get 3 overload errors and I can't figure out where I am going wrong, I haven't written the sorting functions yet I am just trying to get my read and write functions to work properly. Any help would be appreciated. Here is the code -
#include <iostream>
-
using namespace std;
-
#include <fstream>
-
#include <iomanip>
-
using std::setiosflags;
-
using std::resetiosflags;
-
using std::setw;
-
using std::setprecision;
-
-
int read (char filename[], char names[][30], int scores[][3], double averages[]);
-
void write (char filename[], int mode, char description[], char names[][30], int scores[][3], double averages[], int numberOfStudents);
-
//void bubbleSortByName (char names[][30], int scores[][3], double averages[], int numberOfStudents);
-
//void bubbleSortByAverage (char names[][30], int scores[][3], double averages[], int numberOfStudnets);
-
-
char names [100][30];
-
int scores [100][ 3];
-
double averages [100];
-
-
int main ()
-
{
-
-
-
cout << ':' << setiosflags(ios::left) << setw(30) << "hello, world!" << resetiosflags(ios::left) << ':';
-
cout << setiosflags(ios::fixed|ios::showpoint) << setw(7) << setprecision(2) << 3.1415927 << ':' << endl;
-
-
int numberOfStudents = read ("dataHw.txt", names, scores, averages);
-
write ("sortHw.txt", ios::out, "Pre-Sorting", names, scores, averages, numberOfStudents);
-
-
//bubbleSortByName (names, scores, averages, numberOfStudents);
-
//write ("sortHw.txt", ios::app, "Sorted by Name", names, scores, averages, numberOfStudents);
-
-
//bubbleSoryByAverage (names, scores, averages, numberOfStudents);
-
//write ("sortHw.txt", ios::app, "Sorted by Average", names, scores, averages, numberOfStudents);
-
-
return 0;
-
}
-
-
int read (char filename[], char names[][30], int scores[][3], double averages)
-
{
-
-
ifstream infile (filename);
-
if(!infile)
-
{
-
cout << "File not found!";
-
exit(1);
-
}
-
int numberOfStudents = 0;
-
read (infile, names[numberOfStudents], scores[numberOfStudents], averages);
-
while (strcmp(names[numberOfStudents],"zzz")!=0)
-
{
-
numberOfStudents++;
-
read (infile, names[numberOfStudents], scores[numberOfStudents], averages);
-
}
-
infile.close ();
-
-
return numberOfStudents;
-
}
-
-
void write (char filename[], int mode, char description[], char names[][30], int scores[][3], double averages[], int numberOfStudents)
-
{
-
ofstream outfile (filename, ios::out);
-
outfile << description << endl;
-
for (int i = 0; i < numberOfStudents; i++)
-
{
-
-
write (outfile, names[i], scores[i], averages[i]);
-
outfile << endl;
-
}
-
outfile << endl;
-
outfile.close ();
-
return;
-
}
-
|