Help plz with getline

void getEmployeeInfo(EmployeeInfo employees[])
{
employees[0].id = 1; // allow loop to run once
string nameTemp;

for (int i = 0; employees[i - 1].id > 0; i++)
{
cout << "Enter information for employee " << i + 1 << endl;
cout << "Employee ID(0 to quit): ";
cin >> employees[i].id;
if (employees[i].id > 0) // check for input completed
{

cout << "Employee name: ";

cin.ignore(100,'\n');
getline(cin, employees[i].name);

cout << "Pay rate: ";
cin >> employees[i].payRate;

while (employees[i].payRate < 1) //test for validity of pay rate
{
cout << "Invalid input!\n";
cout << "Pay rate: ";
cin >> employees[i].payRate;
}

cout << "Type: ";
cin >> employees[i].employeeType;
while (employees[i].employeeType < 0 || employees[i].employeeType > 1)

{
cout << "Invalid input!\n";
cout << "Type: ";
cin >> employees[i].employeeType;
}

}
}
}

It runs through the cycle fine the first time but when the loop continues it will crash once i input a name the second time. Can anyone help me with why?
nvm i figured it out myself. it was an issure with the employees array setup. thanks.
Topic archived. No new replies allowed.