Array - Don't understand where this function is getting size info
Hi!
This is an excerpt from my book. I am confused about a small thing, where is the void function getting the number for size from ?? @__@
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
|
#include <iostream>
using namespace std;
void showValues(int intArray[], int size); // Function prototype
int main()
{
const int ARRAY_SIZE = 30;
int collection[ARRAY_SIZE] = { 5, 10, 15, 20, 25, 30, 35, 40 };
cout << "The array contains the values\n";
showValues(collection, ARRAY_SIZE);
system("pause>nul");
return 0;
}
void showValues(int nums[], int size)
{
for (int index = 0; index < size; index++)
cout << nums[index] << " ";
cout << endl;
}
|
It is passed to the function as a parameter; see line 11. ARRAY_SIZE is being passed in as the second argument.
Ohhh! I see, thank you very much! :D
Topic archived. No new replies allowed.