I cannot figure out what this error message means?

```
#include <iostream>
using namespace std;
double max_array(const double x[], int max_val);
int main (void)
{
int i, max_val;
double x[max_val];
double array_avg, array_max, array_min;
cout<<"Enter likely number of values: ";
cin>>max_val;
cout<<"Enter values seperated by white space:";
for (i=0;i<max_val;i++)
cin>>x[i];
cout<<"\nThese values were entered: ";
for(i=0;i<max_val;i++){
cout<<x[i]<<" ";
array_max=max_array(x[i], max_val);
}
system("pause");
return 0;
}
double max_array(const double x[], int max_val)
{
double max_int;
max_int=x[0];
for (int k=1; k<max_val; k++)
{
if (x[k]>max_val)
max_int=x[k];
}
return max_int;
}
```

could someone explain to me what i did wrong?