look for and replace information in a file

Hey guys, I'm writing a program which saves information for the clients of a dating service like this:
name lastname address gender age interest1 interest2
Is there any way to change the address of a person that is cin-ed when there are multiple people in the file.
random access writes require all records and fields to be of a fixed size so that you can seek() to them and because when saving an updated record, if it is bigger than its previous version, then it will overwrite the beginning of the next record also.

So if your file contents satisfy that (fixed length records/fields), then its possible but not with the serialise functions << >>, you would need to use file functions, fopen/fseek/fread/fwrite.

if your records and/or fields vary in size then you will be stuck with serialisation unfortunately, and will need to process the entire file.
fopen/fseek/fread/fwrite are the standard C functions.

fstream::open, fstream::seekg, fstream::seekp, fstream::read, fstream::write are the C++ I/O Streams library equivalents.

Andy


Thank you guys so much for the explaining it so well.
Topic archived. No new replies allowed.