Go4Expert (http://www.go4expert.com/)
-   C (http://www.go4expert.com/forums/c/)
-   -   C-pro files (http://www.go4expert.com/forums/c-pro-files-t6290/)

M.Santosh 11Sep2007 17:38

C-pro files
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 11Sep2007 17:46

Re: C-pro files
What format are the rcords in, (csv,tab delimeted?)

M.Santosh 11Sep2007 17:59

Re: C-pro files
The delimiter is tab .

DaWei 11Sep2007 19:43

Re: C-pro files
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 13Sep2007 19:43

Re: C-pro files

All times are GMT +5.5. The time now is 04:31.