Arrays in Functions

Hi all...
I'm having some trouble with a code that I just started. I need to use an array to store 10 user values. Then I need to use a function (highLow in this case) to choose the largest and smallest number from the 10 and display them. SO far this is all I have but I keep getting an error "error C3861: 'highLow': identifier not found"... I thought that I had to use "#include <iostream.h>" but I guess not because it didn't work either. Any feedback and pointers would be appreciated.
Thanks!

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include <iostream>


using namespace std;
int main()
{
	int value[10] = { 0 };
	cout << "Please enter 10 values" << endl;
	cin >> value[0] >> value[1] >> value[2] >> value[3] >> value[4] >> value[5] >> value[6] >> value[7] >> value[8] >> value[9];
	highLow(value[10]);
	return 0;
}

void highLow(int number)
{

}
You need a forward declaration for highLow(). At the time the compiler reads line 10, it doesn't know what the calling sequence for highLow() should be.

Line 10: That's not the correct way to pass an array. You're trying to pass the 11th element of the array, which is out of bounds.

Line 14: The argument to highLow() should be an array of ints. Not a single int.

I thought that I had to use "#include <iostream.h>"

<iostream.h> is deprecated. <iostream> is the standard header.
Last edited on
The compiler is processing a file (almost) line by line.
It does reach line 10 and encounters a new word "highLow".
* That is not a language keyword.
* That was not declared/introduced within file 'iostream'.
* That was not declared/introduced in lines 2-9 of this file.

So what is it? There has been no clue. Because the compiler does not know, it says "error".

There are two solutions. One is to move the lines 14-17 to before line 5.
A better one (and which the file 'iostream' is about too) is to keep the lines 14-17 where they are and insert a function declaration before line 5.

See section Declaring functions in http://www.cplusplus.com/doc/tutorial/functions/
keskiverto-- I declared the function like the link said and all is good... Thank you both.
Topic archived. No new replies allowed.