I am making a program where I input the details of many employees and store it in a text file. How can I make a function to search the entire text file and display the only details of that employee and not anyone else's? The details is always being inputted in append mode. I can't use eof() as it will display the entire document.
This is a school project and we have only studied cin and cout and not std::, hence I am using using namespace std;
EDIT: ADDED SAMPLE TEXT FILE
First name:Test
Last name: asdfas
Employee no: 12
(etc.)
Local Contact: 12323
***********************************************
First name:Test2
Last name: asd
Employee no: 23432
(etc.)
Local Contact: 234324
***********************************************
void hr::empdetails()
{
//declaring all datamembers
char firstname [30], lastname [30], dept[30]; //etc.
ofstream outfile;
outfile.open ("example.txt",ios::app);
//inputting all details
//writing details into text file...
outfile<<"First name:";
outfile<<firstname;
//...................
outfile<<"\nLocal Contact: ";
outfile<<localcon;
outfile<<"\n\n*************************************************";//indicating end of employee's details
}
void hr::searchname()
{
//what should i write here to search for a name and display all of its details
}