1. We have moved from vBulletin to XenForo and you are viewing the site in the middle of the move. Though the functional aspect of everything is working fine, we are still working on other changes including the new design on Xenforo.
    Dismiss Notice

C-pro files

Discussion in 'C' started by M.Santosh, Sep 11, 2007.

  1. M.Santosh

    M.Santosh New Member

    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 ??????????
     
  2. jwshepherd

    jwshepherd New Member

    What format are the rcords in, (csv,tab delimeted?)
     
  3. M.Santosh

    M.Santosh New Member

    The delimiter is tab .
     
  4. DaWei

    DaWei New Member

    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.
     
  5. M.Santosh

    M.Santosh New Member

Share This Page