Reputation: 119
I need help passing a structure through a function to collect and print out its corresponding information. When I try and run the code below the compiler returns that I have too many arguments for the functions.
#include <iostream>
using namespace std;
int num;
void getInput();
void classBank();
struct Record
{
string fname, sname;
int marks, indexNum;
double average;
};
int main()
{
Record student;
getInput();
classBank(student);
}
void getInput()
{
cout<<"How many people are you dealing with: ";
cin >> num;
}
void classBank(struct student)
{
for(int i = 1; i < num; i++)
{
cin >> student[i].fname;
cin >> student[i].sname;
cin >> student[i].marks;
cin >> student[i].indexNum;
cin >> student[i].average;
}
}
Upvotes: 2
Views: 90
Reputation: 134
Replace
void getInput();
void classBank();
with
void getInput();
void classBank(Record student);
EDIT: That code won't work 'cause of several reasons:
struct
meansEDIT2 Typo
Upvotes: 4