Output with structs

For this program, I need to be able to prompt the user 3 times for student record info, and when it is all gathered, print to the console everything that was compiled. It allows me to input the 3 sets of data, but after the third, the program terminates without ever printing. Why?!? The input and output subprograms and calls are pretty much identical...

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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include <iostream>
#include <string>

using namespace std;

struct Student
{
  string name;
  string address;
  string city;
  string state;
  int zip;
  char gender;
  int id;
  float gpa;
}; // Student

void printStudent(Student& s)
{
  cout << "Name: " << s.name << endl;
  cout << "Address: " << s.address << endl;
  cout << "City: " << s.city << endl;
  cout << "State: " << s.state << endl;
  cout << "Zip: " << s.zip << endl;
  cout << "Gender: " << s.gender << endl;
  cout << "ID: " << s.id << endl;
  cout << "GPA: " << s.gpa << endl;
  cout << endl;
}

void inputStudent(Student& s)
{
  cout << "Name: ";
  getline(cin, s.name);


  cout << "Address: ";
  getline(cin, s.address);


  cout << "City: ";
  getline(cin, s.city);


  cout << "State: ";
  getline(cin, s.state);


  cout << "Zipcode: ";
  cin >> s.zip;
  cin.ignore (1000,10);

  cout << "Gender [M/F]: ";
  cin >> s.gender;
  cin.ignore (1000,10);

  cout << "ID: ";
  cin >> s.id;
  cin.ignore (1000,10);

  cout << "GPA: ";
  cin >> s.gpa;
  cin.ignore (1000,10);

  cout << endl;
}

int main()
{

  // declare constants/variables
  const int studentMax = 3;
  Student studentX[studentMax];

  // input students
  for (int i = 0; i < studentMax; i++)
  {
    cout << "Student " << (i+1) << ":" << endl;
    inputStudent(studentX[i]);
  }

  // display students
  for (int i = 0; i < studentMax; i++)
  {
    cout << "Student " << (i+1) << ":" << endl;
    printStudent(studentX[i]);
  }

  return 0;
}
I've also tried just making it so that only one entry could be input, but that didn't seem to give me any help. Any ideas?
Well, I think I see what the issue is. It works fine, so long as the user input is the same as the datatype. If the user enters the wrong data in, it kicks it out. I'll need to fingure a way to restrict it each time.
Topic archived. No new replies allowed.