need help deleting a deleting a struct from file

This is a discussion on need help deleting a deleting a struct from file within the C Programming forums, part of the General Programming Boards category; Hey I have a problem I've been struggling with the last couple of days, I need help deleting a certin ...

  1. #1
    Unregistered
    Guest

    Post need help deleting a deleting a struct from file

    Hey

    I have a problem I've been struggling with the last couple of days, I need help deleting a certin struct from a file. the program is currently saving the struct to a list which is later printed on screen from where I select the number linked to the struct, however the struct does not vanish from the file itself. I need help getting the struct to vanish from the file also. Would be thankfull for any help or suggestions.

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Something like:

    - Load structs from file into link list (or tree or whatever)
    - User selects one to delete
    - Struct is removed from the link list and free()'d from memory
    - User chooses to "save changes" (or maybe its done automatically)
    - Prog then loops through the list, writing each node to the file, overwriting the original (or maybe writing to another file, it's up to you).

    Job done!
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Unregistered
    Guest
    tnx, yeah I know what the flow would look like, but I could use some actual code, just a part or so to get started, I've been fiddling with read/seek cursor etc, still havent been able to get rid of it

  4. #4
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    If you close the file after reading it all in, you can reopen with truncate to delete it's contents ready for writing. Thats as long as you have all the data in your link list.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  5. #5
    Unregistered
    Guest

    Lightbulb

    Tnx for the help, but I solved it another way

  6. #6
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    > Tnx for the help, but I solved it another way
    What way? Let people here know, then they can learn too. It's a two way board y'know
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Assignment HELP!!
    By cprogrammer22 in forum C Programming
    Replies: 35
    Last Post: 01-24-2009, 01:24 PM
  2. gcc link external library
    By spank in forum C Programming
    Replies: 6
    Last Post: 08-08-2007, 03:44 PM
  3. multiple file loading. so fruturated! help!
    By psychopath in forum Game Programming
    Replies: 5
    Last Post: 05-09-2005, 05:13 PM
  4. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 09:33 AM
  5. Contest Results - May 27, 2002
    By ygfperson in forum A Brief History of Cprogramming.com
    Replies: 18
    Last Post: 06-18-2002, 01:27 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21