I am trying to add a numbering system to a list in a datafile:
Appointments.open(DATAFILE);
if (Appointments.is_open())
{
// Read the file until it's finished, displaying lines as we go.
while (!Appointments.eof())
{
getline(Appointments, line, '\n'); // getline reads a line at a time
appointment.push_back(line);
cout << i << ". " << line << endl;
i++;
}
Appointments.close();
}
So the proper output should be:
1. 12 August 2010 Test
2. 13 August 2010 Test2
However the output comes out as:
1. 12 August 2010 Test
2. 13 August 2010 Test2
3.
How do I get rid of the extra 3?