Friday, July 31, 2009

I hav one C++ assignment..In which I need to maintain employee record.with add delete modify display?

It is written that all data shd be stored in file


So what I need to do


how to delete data in text files tht is previously created..

I hav one C++ assignment..In which I need to maintain employee record.with add delete modify display?
In your ofstream object's open method there is an optional "mode" parameter. You can set this mode parameter to "ios::trunc" which will truncate or "erase" the contents of the file (if it exists) before writing the new content. This mode parameter can also be bitwised together with other mode options. Below is an example...





ofstream myfile;


myfile.open ("example.txt", ios::out | ios::trunc);





The example above opens example.txt for "out" operations and truncates the contents of the file before outputting the new material.





NOTE FOR OTHER ANSWERER: Probably the assignment is designed to practice file handling operations.





Good luck on your assignment!
Reply:I'm missing your point here slightly, Why would you store the data in a text file?





just write the display fresh every time the page re-loads or an update takes place or overwrite the text file with the correct file when updates are made, attempting to perform an edit on a text file could be very problematic as users can access and modify text files and your edit criteria would have to take into account every thing they could do to it that would impact your editing, too much to hassle with, just re-write it instead.


No comments:

Post a Comment