0

help me~~~

what's wrong with it?!

```
#include <iostream>
#include <iomanip>
#include <cmath>
#include <fstream>
using namespace std;
void minMax(const double, int, double&, double&);
void numMeasures(const double, int, double&, double&);
void getData(fstream&, double, int&);
int main()
{
double count, min, max, mean, var;
double data[400];
count = 25;
/* how can I 'count' the number of measurements read from the file?*/
char file;
cout<<"Enter the name of the data file>";
cin>>file;
ifstream dataFile;
dataFile.open("file");
if(dataFile.fail())
{
cout<<"file did not open, please check it"<<endl;
system("pause");
return 1;
}
cout<<endl;
cout<<endl;
cout<<"Descriptive Statistics"<<endl;
cout<<"------------------------------"<<endl;
while(dataFile)
{
getData(dataFile, data[], count); //**error**//
minMax(data[], count, min, max); //**error**//
cout<<"Min:"<<setw(20)<<setprecision(4)<<min<<endl;
cout<<"Max:"<<setw(20)<<max<<endl;
float range;
range = max - min;
cout<<"Range:"<<setw(20)<<range<<endl;
numMeasures(data[], cout, mean, var); //**error**//
cout<<"Mean:"<<setw(20)<<mean<<endl;
cout<<"Variance:"<<setw(20)<<var<<endl;
float s_d;
s_d = sqrt(var);
cout<<"Standard Deviation:"<<setw(20)<<s_d<<endl;
}
system("pause");
return 0;
}
void minMax(const double data[], int count, double& min, double& max)
{
min = data[0];
max = data[0];
for(int i=0; i<count; i++)
{
if(data[i] > max)
max = data[i];
else if(data[i] < min)
min = data[i];
}
}
void numMeasures(const double data[], int count, double& mean, double& var)
{
double sum_mean = 0;
for(int i=0; i<count; i++)
sum_mean += data[i];
mean = sum_mean / count;
double sum_var = 0;
for(int j=0; j<count; j++)
sum_var += (data[j] - mean);
var = sum_var / (count-1);
}
void getData(fstream& dataFile, double data[], int& count)
{
int amountRead = 0;
int max_read = 400;
while(dataFile>>data[amountRead] && amountRead<max_read)
amountRead++;
}
```

*Edited 6 Years Ago by Dani*: n/a