Arrays with textfile data(help)

I am making a program that will take the input of x amount of numbers on oneline that it will calculate the amount of data, and growth, and average. The average of the tree growth will be compared to each value. So if the average is 3inches and the tree grew one inch, the program will say the tree grew 1 inch which is -2 away from the average. I have the program started, but have no clue what to do next. Thank you for any help.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include <iostream>
#include <string>
#include <fstream>
#include <cmath>
#include <iomanip>

using namespace std;
void weatherfunction(ifstream&);//function prototype says that ifstream will be used in the function  

int main()
{
		ifstream weatherfile("tree.txt");//allows file to be opened 
	weatherfunction(weatherfile);//tells the program that the tree will be used and opened in this file.
		weatherfile.close();//closes treefile
	
	return 0;//return value at the end.

}
void weatherfunction(ifstream& file)//allows file to be opened, and used with ifstream&. The ifstream says it will be a treefile.
{


	if (!weatherfile)//if statement to check if the file has opened correctly
	{
		cout<<"Please try again, unable to open text file"<<endl;//output if file does not open correctly
		
	}

Last edited on
It would be helpful to me to see a sample of your data, tree.txt...

My advise is to do it on paper, figure out how to do it there then use that to code it.
Topic archived. No new replies allowed.