Hi... I'm trying to write a program that reads data(numbers) from a text file into an array, finds the average and sorts it in ascending order then outputs the result into a txt file. Here's what I've done so far... it's not running, pls help
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main ()
{
float gradeData[12]; //creates array to hold names
//short count1; //for loop for input
float count;//holds data read from the rainfall.txt file per line
float holdData;
ifstream myfile ("rainfall.txt");
cout<<"Opening file ::: Filename ::: grades.txt";
if (myfile.is_open())
{
while (! myfile.eof() ) //while the end of file is NOT reached
{
getFloat (myfile,holdData); //get one line from the file
gradeData[count] = holdData;
cout<<gradeData[count]<< endl; //and output it
count++;
}
myfile.close(); //closing the file
}
else cout<<"Error ::: Unable to open file"; //if the file is not open output
system("pause");
return 0;
}
Everything is supposed to be in functions.... I don't know where to start.... if you don't want to give the full answer no problem.... if I see some examples I should be fine. I'll really really appreciate the help.... Yes the code is not complete... don't know how to proceed.