Can anyone help me to retrieve data from the file. How do I display the appointment of Peter with fstream
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
|
void searchRecords()
{
ifstream someStream( "appointment.txt" );
// Set up a place to store our data read from the file
string line;
cout<<"Please enter user";
cin>>line;
// Read and throw away the first line simply by doing
// nothing with it and reading again
getline( someStream, line );
// Now begin your useful code
while( !someStream.eof() ) {
// This will just over write the first line read
getline( someStream, line );
cout << line << endl;
}
|
Dexter, 10thOct12 - 9am , Training room
Peter, 15thoct 12 - 10am, discussion room 2
Jane, 10thOct12 - 11am, meeting room 1
Liam, 9thOct12 - 8:30am, meeting room 2
Parry, 8thOct12 - 9am, meeting room
Liam, 7thOct12 -12pm, Conference room
Richard, 10thOct12 - 9am , meeting room 1
Peter, 15thoct12 - 10am, meeting room 2
Jane, 3rdOct12 - 5pm, Lab 1