Thread: Files in C

  1. #1
    Registered User
    Join Date
    Jan 2006
    Posts
    2

    Files in C

    Hi all,

    I have a problem in handling files through C.

    here is the problem im having:

    i will query the database (for instance consider employees table )
    for empno,ename,job,salary fields.The query returns me some 100 of rows. now i need to place them in a file in row wise pattern as they exist in the database.

    now , if any row is updated in the database i need to update the same row in the file . also if any row is deleted i need to remove the same row in the file , and if any new row is inserted into the data base i need to insert the row in the file.

    can any one suggest me any method to do this .
    The performance is and main criteria(i mean time to do file operations. )

    please help me in this regard,

    thanks in advance,


    Trinath Somanchi,
    Hyderabad.

  2. #2
    Registered User
    Join Date
    Nov 2004
    Location
    USA
    Posts
    516
    I suppose you have a table with all the information about one employee on one line.
    You can consider taking in each line using fgets() , and writing it to another file.
    If a line is deleted, pass the line number to the linedeletion function, ignore (n-1) endofline characters '\n' and delete the line that the file pointer now points to, that is, delete characters from that position till you encounter the next '\n' or replace them with blankspaces, whichever suits you.
    Code:
    >+++++++++[<++++++++>-]<.>+++++++[<++++>-]<+.+++++++..+++.[-]>++++++++[<++++>-] <.>+++++++++++[<++++++++>-]<-.--------.+++.------.--------.[-]>++++++++[<++++>- ]<+.[-]++++++++++.

  3. #3
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,666
    I'm sure a search for "employee database" will work....

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Ressources files
    By mikahell in forum Windows Programming
    Replies: 4
    Last Post: 06-19-2006, 06:50 AM
  2. add source files to embedded VC 4.0
    By George2 in forum C++ Programming
    Replies: 4
    Last Post: 06-13-2006, 03:28 AM
  3. *.cpp and *.h files understanding
    By ElastoManiac in forum C++ Programming
    Replies: 4
    Last Post: 06-11-2006, 04:45 AM
  4. Linking header files, Source files and main program(Accel. C++)
    By Daniel Primed in forum C++ Programming
    Replies: 3
    Last Post: 01-17-2006, 11:46 AM
  5. Multiple Cpp Files
    By w4ck0z in forum C++ Programming
    Replies: 5
    Last Post: 11-14-2005, 02:41 PM