Thread: c database

  1. #1

    Unhappy c database

    how can i delete a perticular record directly i.e without rewriting all records in a new file then delete the first file for text files...
    fwrite() func.. writes a record for delete what ?...plese help me

  2. #2
    Registered User zahid's Avatar
    Join Date
    Aug 2001
    You can do that using:

    [ Never code before desk work ]
    A man who fears Nothing is the man who Loves Nothing
    If you Love Nothing, what joy is there in your life.
    =------------------------------------------------------= - I may be wrong.

  3. #3
    If you want to delete a record from a file in this way then you need to understand the difference between a logical and a physical delete.

    With each record in the file, you need to store an indicator to allow you to determine if the record is valid (ie used).
    For text files you may simply wish to delete (logically) the record by replacing the original contents with whitespace (depending on the rules for your text file).

    If you want to physically delete a record then you must rewrite the entire file.

    However, for efficiency, it is better to perform a logical deletion, whereby the record to be deleted is marked to indicate that it is no longer valid. You would then attempt to reuse the empty records within the file the next time an insert was attempted.

    If you then wanted to improve the efficiency of locating empty records, you could simply link the empty records using a simple list and could store the head of the link in the file header.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. literature database: help with planning
    By officedog in forum C++ Programming
    Replies: 1
    Last Post: 01-23-2009, 12:34 PM
  2. Creating a database
    By Shamino in forum Game Programming
    Replies: 19
    Last Post: 06-10-2007, 01:09 PM
  3. Replies: 10
    Last Post: 05-18-2006, 11:23 PM
  4. Developing database management software
    By jdm in forum C++ Programming
    Replies: 4
    Last Post: 06-15-2004, 04:06 PM
  5. Making a Simple Database System
    By Speedy5 in forum C++ Programming
    Replies: 1
    Last Post: 03-14-2003, 10:17 PM