Too few arguments to function

I just created this void and wanted to use it in my int main ().
But it gives the following error: too few arguments to function
How can i resolve this?

My void:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
void display_members(Member member_array[], int& amountofmembers)
{
    assert (amountofmembers > 0);
    string gender_and_paid;
    cout << "Surname \t Forename \t Street+housenr \t Postcode \t City \t M/F \t Paid" <<
        "____________________________________________________________________________";
        for (int counter=0; counter < amountofmembers; counter++)
        {
            if (member_array[counter].gender == Male)
            {
                gender_and_paid = "M";
            }
            else
            {
                gender_and_paid = "F";
            }
            if (member_array[counter].paid)
            {
                gender_and_paid += "yes";
            }
            else
            {
                gender_and_paid += "No";

            }
       cout << member_array[counter].surname << " "<< member_array[counter].forename  << " \t" << member_array[counter].street_name << " \t" << member_array[counter].postcode
            << " \t" << member_array[counter].city_name << "\t"  << member_array[counter].year_of_birth << " \t";

        }
}


1
2
case 1 :
        display_members();
I just created this void


No, you created a function.

But it gives the following error: too few arguments to function

You're calling it incorrectly. You must feed it two parameters when you call it. How many are you passing in at the minute? Let's see:
display_members();
Zero.
How many does it want?
void display_members(Member member_array[], int& amountofmembers)
Two.
Last edited on
this might have been a mistype but you can't use that in int main(). You would use that outside of it and "link" (I can't think of the proper term) it to int main() by using display_members(value, value)
Topic archived. No new replies allowed.