variable has incomplete type "void"

I'm writing a simple program for homework, and I'm getting an error I can't explain.

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
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#include <iostream>
#include <string>
using namespace std;

void convertmoney(int money, int &nbrhundreds, int &nbrfifties, int &nbrtwenties, int &nbrtens, int &nbrfives, int &nbrones);

int main ()
{
    const int arraysize = 20;
    string firstname[arraysize];
    string lastname[arraysize];
    string phonenumber[arraysize];
    string email[arraysize];
    
    int moneyamount = 0, hundreds = 0, fifties = 0,twenties = 0, tens = 0, fives = 0, ones = 0;
    
    for (int i = 0; i < 20; i++)
    {
        cout << "What is your first name?" << endl;
        cin >> firstname[i];
        
        cout << "What is your last name?" << endl;
        cin >> lastname[i];
        
        cout << "Email address?" << endl;
        cin >> email[i];
        
        cout << "Phone number?" << endl;
        cin >> phonenumber[i];
        
        cout << "Money that needs to be converted?" << endl;
        cin >> moneyamount;
        
        void convertmoney(moneyamount, hundreds, fifties, twenties, tens, fives, ones);
        
        cout << "Hello " << firstname[i] << " " << lastname[i] << "," << endl;
        cout << "Email: " << email[i] << endl;
        
        cout << hundreds << endl;
    }
    
    return 1;
}



void convertmoney(int money, int &nbrhundreds, int &nbrfifties, int &nbrtwenties, int &nbrtens, int &nbrfives, int &nbrones)
{
    nbrhundreds = money%100;
}


Line 34 is where my xCode compiler tells me that the variable has incomplete type "void". Any idea why?
Last edited on
You have a function declaration inside of another function, which is illegal. Note that you already declared that function above, so if you delete that line, you'll be just fine. However, it looks like you're trying to call the function such that it'll modify 'hundreds': to do this, just omit the keyword void and it should work like I think you intended it to.
Topic archived. No new replies allowed.