0
How to delete a selected data from a file
Hey guys I am working on a project. In my project i have a option called modify data. When you use that You need enter the student's roll no to modify that students data. example the student current data is Name : McAwesome Roll : 102 now you choose that option modify data and enter 102 and put the name McRAS and roll 103 how I do that ?? how I make that code to find that data inside my file which contains the roll no 102 and let the use to modify that data?? please help me
2 ответов
+ 2
The simplest thing you can do is read all data entries from the file one by one, and write them to a temporary file only if they don't match the data to be modified. When the data is a match, you modify that object data and then write it in the temporary file. In the end, you delete the original file and rename the temporary file to the original name.
If you don't want to use multiple files, you may use seekg, to reach each object's roll number one by one, just read the roll number, and if its match, go back to the start of that object and overwrite data at the same position again. This method, however requires you to know the exact size of the object so that you can know where to read/write from/to.
0
ok thank you
I am working on it