Jan 6, 2013 at 6:44pm UTC
I want to write a programme (in C) that writes students information in a file and then the user says a student number & i have to remove all about that student in the file
how can i do that?!
(erasing somethin special in a file)
thx alot! :)
Jan 6, 2013 at 8:04pm UTC
The simplest (and possibly the only way) is to read the whole file in buffer, remove the stuff you don't need from the buffer, empty the file and write the buffer in the file.
Jan 6, 2013 at 9:35pm UTC
but how to remove?! ( i mean what is the syntax (code) )?
sry, i am just a begginer! :D
Jan 7, 2013 at 10:08am UTC
I wont give you the code. The code is your assignment. But I will expand a bit my answer.
Lets assume you have a class which holds students record.
When you read the file, store each students record in an std::vector. Close the file afterwards.
Then delete the entries of students who you don't need.
Reopen the file with truncating the file ( it's now completely empty).
Write the contents of std::vector in the file.
You can find information for each individual step in this site or google.