Struct/Function error?

Gives this error: In function 'int main()':
13:18: error: too many arguments to function 'void printE()'
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#include <iostream>

using namespace std;
void enemyCheck();
struct enemies {
  int Bandit;
};


int main() {
    char response;
    enemies sFrank;
    sFrank.Bandit = 10;
    enemyCheck(sFrank);
    cin >> response;
    
}
void enemyCheck(enemies senemies) {
    cout << senemies.Bandit;
}
I get a different error. also I see no function called printE().

i get
1
2
3
4
 
In function 'int main()': 
14:22: error: too many arguments to function 'void enemyCheck()' 
4:6: note: declared here


line 4 is missing parameters, C++ can have many functions with the same name so long as their parameters are different. eg; func(int); func(float); func(char); and these are all different and separate functions.

so the function you declared at line 4 is not the same one that you defined at line 18.

line 4 should read...
void enemyCheck(enemies senemies);
That error was the old name I tried rehanging the name to something else to see if it was something weird,and yeah that was the same error I was getting.
Anyways I modified the code and fixed it, I added the argument/parameters in and got another error, but I fixed it when I placed it after the struct. Makes sense now that I think about it. This was just a test btw.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21

#include <iostream>

using namespace std;
struct enemies {
  int Bandit;
};
void enemyCheck(enemies senemies);

int main() {
    char response;
    enemies sFrank;
    sFrank.Bandit = 10;
    enemyCheck(sFrank);
    cin >> response;
    
}
void enemyCheck(enemies senemies) {
    cout << senemies.Bandit;
}
Topic archived. No new replies allowed.