I'm having a secondary problem as well. I have defined my array, written my functions, and all compiles well, but I'm getting two linking errors that say my hourly temp array is already defined in my test.cpp (main)...uhh, I dunno how to find out how/where to fix it.

You can not put array declarations in a header file then include that header file in two or more *.cpp files. If that's what you did then you should declare the array with the extern keyword everywhere except in ONE and only ONE *.cpp file.

// header file
[b]extern[/b] int array[8];

Then in a *.cpp file declare it again without the extern keyword.

commented: he knew what I did without even seeing my code +1

that's exactly what I did, thank you....if you don't mind, back on the third page at the bottom I asked a question about calling display functions.

I have a function written to display my output, but I've never called a display function before and I'm not sure how to do it. Here is the function

void displaytemp( const int hourlytemps[], int numtemp, double averagetemp)
{
	cout << " Average Temperature: " << averagetemp << endl;
}

how do I call this in main?... I know it's not really necessary to create an output function, it's just practice writing functions and calling stuff from arrays and other functions

Call it just as you would any other function

int main()
{
    int hourlytemps[24];
    int numtemp;
    double averagetemp;

    displaytemp( hourlytemps,numtemp, averagetemp);
}

Your function displaytep() is also incorrect. You can't display an array like that -- have to print each element one at a time, something like this:

displaytemp( const int hourlytemps[], int numtemp, double averagetemp)
{
    for(int i = 0; i < numtemp; i++)
   {
          cout << hourlytemps[i] << "\n";
   }
}

Yes, I have a different function for the tabular display, that function is purely for displaying the average of the 24 temps

Oops! I see that now. Your function is correct afterall. Please forgive an old man -- blind in one eye and can't see out of the other :)

Still problems though, I have a function for high and low temps, low temps always shows 1 and high temp shows 23 unless they are all the same.

int lotemp( int hourlytemps[], int numtemp)
{
	int lowtemp = hourlytemps[0] ;

	for( int i=1 ; i < numtemp ; ++i )
	{
	  if(lowtemp > i)
		 lowtemp = i;
	}
	return (lowtemp);
}

High is the same, just change the sign

line 7 is wrong. Should be testing against hourlytemps, not the loop counter. if( lowtemp > hourlytemps[i])

Okay, hitemps, still comes out to 23, here is the code

int hitemp( int hourlytemps[], int numtemp)
{
	int hitemp = hourlytemps[0] ;

	for( int i=1 ; i < numtemp ; ++i )
	{
	  if(hitemp < hourlytemps[i])
		 hitemp = i;
	}
	return (hitemp);
}

I'll have to read up again to remind myself how to do the line numbers, apologies for that

>>I'll have to read up again to remind myself how to do the line numbers, apologies for that
Not a problem -- I just like to see them. Here's how

[code=cplusplus] // your code here

[/code]


line 8 is also wrong in this and the previous post. should be hightemp = hourlytemps[i];

hehe, okay, now I feel like an idiot, you'd think I'd never found a min or max before...of course, I haven't with an array..lol..thats going to be hard to get used to. Now have have to learn pointers...weeeeee

Thank you yet again, the entire program actually works now.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.