How do I reference this?

"1. Read the rainfalls: Prompt for and get the input file name and try to open the file. If the file opens, read the rainfalls from the file, store them into the array, and return 0. If the file does not open, print an error message on the console and return -1. If the file is not found, do NOT process the rainfalls or attempt to write to the output file"


I'm really having trouble with the first array. This is an example of the inputs and info needed for the function.

//Function Prototypes

int main()
{
int main() {

//get inputs
const int MONTHS = 12;

string monthName[MONTHS] = { "January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"};
double rainfallAmount[MONTHS] = {2.91, 2.60, 3.86, 3.19, 3.46, 3.27, 4.61, 3.39, 4.06, 3.03, 2.95, 3.39};
int count=0;
double avg;
double totalRain, mostRain, leastRain;
string name, mostMonth, leastMonth;

// open outfile
ofstream outFile;
outFile.open("out6.txt");


cout << "YEARLY MONTHLY RAINFALL" << endl;
cout << "Month"<<setw(20)<<"Rainfall in inches"<<endl;


for (int count = 0; count < MONTHS; count++) {
cout << monthName[count]<<setw(17)<<rainfallAmount[count]<<endl;

}

//close the outfile
outFile.close();

return 0;
}

"1. Read the rainfalls: Prompt for and get the input file name and try to open the file.


Why don't you do it? You just use a given name "out6.txt"
Topic archived. No new replies allowed.