You should check that i < 4557 in the while loop before the getline call, and presumably use a named constant instead of 4557.
Also, this is probably wrong:
Code:
if (!holder.find(first, 0))
Perhaps it should be:
Code:
if (holder.find(first) == string::npos)
Oh, and since you are going to overwrite holder on the next iteration anyway, I would rather change this:
Code:
holder.erase(0, 3);
data[i].name = holder;
to:
Code:
if (holder.length() > 3)
{
data[i].name = holder.substr(3);
}
data[i].name should be an empty string to begin with, and this way seems a bit more intuitive, i.e., copy a substring rather than shorten a string and then copy it.
Personally, I would move the struct database definition to file scope, but still declare data to be local to main.