NEED HELP ASAP!!

my text file include
id
name
ic
gender
dob

void searchAdministratorID()
{
system("CLS");
string line;
string ID;
fstream searchfile;
searchfile.open("administrator.txt");

cin.ignore();
cout<<"Enter ID number: ";
getline(cin,ID);

if(searchfile.is_open())
{
while(!searchfile.eof())
{
getline(searchfile, line);
if(ID == line)
{
for (int i = 0; i < 5; i++)
{
cout << line << endl;
getline(searchfile, line);
}
break;
}
}

}

searchfile.close();
}

I have complete search id coding. The problem how can i search for second row which is name.
I have tired use back the same coding but only can display name, ic, gender and dob.

Read in 5 lines at a time
assign lines to: id, name, ic, gender, dob
Then you can look for smith, who is female/male.

Another way would be combine the 5 lines into one string.

I'm a beginner can you show me how to combine?
Anyone can help me?
Topic archived. No new replies allowed.