student information in c++ fstream

Oct 2, 2014 at 7:05am
how to add a record,
how to edit a record,
how to search the record,
how to delete the record

using a text file or file handling in c++

Here's the following code...
Last edited on Oct 3, 2014 at 1:15pm
Oct 2, 2014 at 8:15am
A text file has sequential access. So unless the records are exactly the same length, which is not the case in a text file, you need to read it into memory, make your changes, then rewrite the file.
Oct 2, 2014 at 10:27am
we need code to start off with...
Oct 3, 2014 at 11:55am
I won't write any code unless you're really stuck; it more about teaching you how to fish rather than giving you fish.

You need to define your record. It seems your record has a: name, id, course.

Then you need to create a collection of records which is filled in when you read the file. A collection is a vector, list, set, map, ... If you're not sure what to use, start with vector. Later on you may need to change to something more convenient.

If you need to change a record, you need to search for the one you're interested in and change the details.

At the end, you overrite the file with the content of the collection.
Topic archived. No new replies allowed.