0

I have this program for school it gets data about a student, does a few calculations and stores the data in a struct which is returned by the input function.

Right now I've only got it working for one student, but I need to be able to store and output data for more than one student.

Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
tail_recursion
  • 660
  • 1
  • 7
  • 11
  • 1
    You might server yourself better by breaking this down to code which focuses specifically on the problem. It's not entirely clear what you are asking. – kfsone Oct 06 '13 at 09:06

1 Answers1

1

"Right now I've only got it working for one student, but I need to be able to store and output data for multiple students."

Use std::vector

int n; //No. of student

std::vector<studentType> vec;
studentType s;

for(size_t i =0; i<n ;++i)
{
  s = input();
  vec.push_back(s);
}

And then you can access

vec[i].studentID ; // etc, for ith student

On another note, void main is not legal C++, use int main

P0W
  • 46,614
  • 9
  • 72
  • 119