PDA

View Full Version : file handling in c++


fariha
08-02-2003, 03:24 AM
hello all!


problem! im creating the database of a college in c++. it contains records of students. im using file handling for this purpose. i write the data on the file using xyz.write and i used xyz.read to read the data, but if i enter over 1 record, and then read the data i have stored, it simply shows me the last record i entered. i suppose the data i enter gets over written. there is an append mode for this purpose, to add to existing file and not over write it. it looks something like this: "ios::app", but where exactly in the program do i use this? can i use it anywhere with the xyz.write function?
plz help, URGENT

DNAunion2000
08-02-2003, 04:02 AM
/*DNAunion*/ C++ maintains two file "pointers" for an input/output file stream: one points to the position where the next read will occur (a "g"et pointer) and the other points to the position where the next write will occur (a "p"ut pointer). If you are not repositioning the "put file pointer", then your program will continue to write to the same record each time.

Check out the seekp() function.