erasing in files

hi
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! :)
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.
thx
but how to remove?! ( i mean what is the syntax (code) )?

sry, i am just a begginer! :D
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.
I got it, thx alot! :)
Topic archived. No new replies allowed.