highest value in the array problem

I don't know why im getting that error can anyone help

#include <iostream>
#include <iomanip>

using namespace std;
int main ()
{
int const SIZE= 12;
double rainfall[SIZE];
double totalrainfall= 0;
for(int x=0; x<SIZE; x++)
{
cout<<"Type amount of rainfall for each 12 months "<<x+1<<endl;
cin>>rainfall[SIZE];
totalrainfall+= rainfall[SIZE];
}

int a;
int highest;
highest = SIZE[0];//<-- error expression must have object to pointer type
for (a= 1; a <SIZE; a++)
{
if(SIZE[a]>highest)
highest = SIZE[a];
cout<<"The highest value is "<<highest<<endl;
}
}
highest = SIZE[0];//<-- error expression must have object to pointer type

Your array is not called SIZE, it's called rainfall[] ;)

if(SIZE[a]>highest)

Your array is not called SIZE, it's called rainfall[] ;)

If you can't see that, just try a search & replace and replace SIZE with 12 and you will see your error more clearly.
Last edited on
Ok that fixed
But then then i get this error

Run-Time Check Failure #2 - Stack around the variable 'rainfall' was corrupted
Topic archived. No new replies allowed.