how to store a node on hard disk

This is a discussion on how to store a node on hard disk within the C Programming forums, part of the General Programming Boards category; when we make a node while programming as soon as the programm finishes it is lost or so to say. ...

  1. #1
    Registered User
    Join Date
    May 2002
    Posts
    9

    how to store a node on hard disk

    when we make a node while programming as soon as the programm finishes it is lost or so to say. at which address
    was the node stored cant be know ,unless those address were being stored in some file.even if we store that. it is not neccessary
    that the node would be found there when again i run a new programm to search for the nodes which i created in some other programm.there are chances that one or two nodes might still
    be found on ram.but if immediatly done.what if i was to find the nodes which i created today after two three days and meanwhile
    all my neighbours were watching movies on my computer
    certainly the space occupied by the nodes would have been used by the newly run programmes.only way to make a node permanent is to store it on hard-disk.but i dont know how to store some thing on hard disk and is its pattern of accessing the address or memory locations similar to the way we access memory locations on ram.ofcourse when i create a text file it is stored at some permanent memory location that is why i can open it anytime i want to but that is a inbuilt utility of c that it automatically stores it at some address or what ever it does to make it permanently available.but what if i want to store the node somewhere permanently.

  2. #2
    End Of Line Hammer's Avatar
    Join Date
    Apr 2002
    Posts
    6,231
    Under normal circumstances, anything you create in memory will be freed up when your program exits. There would be no way to get back to it, even if you new the address, as the OS could and would reuse that memory at anytime.

    Some OS's support shared memory segments, which you can initialise in one program, and they last until a program (either the same one, or a different one), explicitly free them. (Reboot also clears them)

    However, if you are just looking to store data, then disk is the place. Try investigating fopen(), fclose(), fread(), fwrite().

    Post again if this doesn't help you.
    When all else fails, read the instructions.
    If you're posting code, use code tags: [code] /* insert code here */ [/code]

  3. #3
    Registered User
    Join Date
    May 2002
    Posts
    9

    not what i want

    the functions you have given are for files
    i am not using files
    i want to store an independent node on harddisk
    as i understand i might have to access fat for that
    but i dont know
    i dont want to use c feature of files
    cant a node be stored on the hard disk as the scattered data
    if fat has to be accessed then how?

  4. #4
    Code Goddess Prelude's Avatar
    Join Date
    Sep 2001
    Posts
    9,796
    >i am not using files
    You should be if you want to store anything and get it back later.

    >i want to store an independent node on harddisk
    Memory addresses assigned to your nodes will change when the program ends so you can't save the address. You need to save the contents of the node in a file and retrieve it later, rebuilding the list.

    >i dont want to use c feature of files
    Files are not a C feature, C just makes use of them because that's the sensible thing to do. Take UNIX for example, everything is a file so it is only logical to read from and write to files.

    >cant a node be stored on the hard disk as the scattered data
    Sure, but the real question is do you want that data back at some point? If you said yes then you're going in the wrong direction.

    -Prelude
    My best code is written with the delete key.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Replies: 3
    Last Post: 12-06-2008, 07:54 PM
  2. Following CTools
    By EstateMatt in forum C Programming
    Replies: 5
    Last Post: 06-26-2008, 11:10 AM
  3. Memory Leak
    By jtullo in forum C Programming
    Replies: 7
    Last Post: 12-11-2006, 11:45 PM
  4. Binary Tree, couple questions
    By scoobasean in forum C Programming
    Replies: 3
    Last Post: 03-12-2005, 09:09 PM
  5. Replies: 3
    Last Post: 03-04-2005, 02:46 PM

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