C-pro files

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

  1. M.Santosh

    M.Santosh New Member

    Joined:
    Sep 10, 2007
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    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

    Joined:
    Aug 13, 2007
    Messages:
    135
    Likes Received:
    0
    Trophy Points:
    0
    Occupation:
    VP Technology Corporation
    Location:
    Texas
    Home Page:
    http://www.officialhackers.com
    What format are the rcords in, (csv,tab delimeted?)
     
  3. M.Santosh

    M.Santosh New Member

    Joined:
    Sep 10, 2007
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    The delimiter is tab .
     
  4. DaWei

    DaWei New Member

    Joined:
    Dec 6, 2006
    Messages:
    835
    Likes Received:
    5
    Trophy Points:
    0
    Occupation:
    Semi-retired EE
    Location:
    Texan now in Central NY
    Home Page:
    http://www.daweidesigns.com
    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

    Joined:
    Sep 10, 2007
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice