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.

1
  • 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. Commented Oct 6, 2013 at 9:06

1 Answer 1

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

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.