| Charcoalman (28) | |||
Can anyone help me to retrieve data from the file. How do I display the appointment of Peter with fstream
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 | |||
|
|
|||
| Need4Sleep (532) | |
| what errors are you getting or what do you not understand? you need to be very specific in your questions. | |
|
|
|
| Charcoalman (28) | |
|
Currently, there are no errors. // Set up a place to store our data read from the file string line; cout<<"Please enter user"; cin>>line; After keying in user - Liam. I want just the result Liam, 9thOct12 - 8:30am, meeting room 2 Liam, 7thOct12 -12pm, Conference room but now it is showing everything 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 - How do i write the code so that they only take the line with Liam | |
|
|
|
| Charcoalman (28) | |
|
Anyone can help me ???? I need help with my assignment .. i can pay you if you can help me :( | |
|
|
|
| whitenite1 (705) | |||
I believe a big problem is you're overwriting the users name request request.cin >> line; with getline( someStream, line );You would need two strings, one for request, the other for the read files input. After each read line, have a loop to read from the beginning to the first comma, and assign a variable its content.
I didn't check this code for errors, since I don't have your full program, but you should be able to correct any problems it has. Hope this helps.. | |||
|
|
|||
| SamuelAdams (185) | |||
cin>>line; is incorrect because your getting "line" belowgetline( someStream, line );change cin>>line; to cin >> UserName; for the name to search.after your getline( someStream, line );You have no method to tell if UserName is part of "line".
| |||
|
Last edited on
|
|||
| Charcoalman (28) | |
|
thanks for your help .. there wasn't error , but after keying in the name. the program stops sent you a PM whitenite | |
|
Last edited on
|
|