C-pro files

M.Santosh's Avatar, Join Date: Sep 2007
Light Poster
Let us consider, one file contains 10 records of student details.

Now i want to go to 6th record and above to that i want add a new record.

how to this plz!!!!!!!!!!!!! help ??????????
jwshepherd's Avatar, Join Date: Aug 2007
Team Leader
What format are the rcords in, (csv,tab delimeted?)
M.Santosh's Avatar, Join Date: Sep 2007
Light Poster
The delimiter is tab .
DaWei's Avatar, Join Date: Dec 2006
Team Leader
The simplest way is to read in the records and write them to a temp file until you get to the point of insertions. Then write the new record(s) to the temp file. Then read the remaining records and write them to the temp file. Then rename the temp file to the original file name.

You can also read or seek to the point of insertions, read all the remainder of the file to a buffer, seek back to the point of insertion, insert the new data, then rewrite the buffered material. It is more complicated, prone to error, and may require a very large buffer.

Unless you write your own extremely low-level disk access mechanisms, you aren't able to break the chain of information, insert new material, and rechain (like a linked list). Even if you did, you'd have to contend with rewriting parts of sectors if the insertion point didn't happen to coincide precisely with sector end/beginning.

Choose #1.
M.Santosh's Avatar, Join Date: Sep 2007
Light Poster
thanku