Thread: nodes

  1. #1
    Registered User
    Join Date
    Nov 2003
    Posts
    4

    nodes

    if i have a class object w/ 50 nodes attached (each one a pointer to another), and save it using write(), how would i load back in that object? and how would i know the size of it if i load it back in again?

  2. #2
    Registered User
    Join Date
    May 2003
    Posts
    1,619
    Well, if you just did a write, all you would do is write to disk the logical address of the first data member -- in other words, a useless number.

    You need to do a custom read/write. Create a format for your data, and use it.
    You ever try a pink golf ball, Wally? Why, the wind shear on a pink ball alone can take the head clean off a 90 pound midget at 300 yards.

  3. #3
    Registered User
    Join Date
    Nov 2003
    Posts
    4
    so your saying that i would need to write each node individually to the file?

  4. #4
    Registered User
    Join Date
    Nov 2003
    Posts
    4
    actually... what IM really asking is... if i have a pointer to an object in my class and use the new keyword w/ it... and save it using write... does the data the pointer points to carry over to the file so that i can read it if i know the filesize (it could be NULL)?

  5. #5
    and the hat of int overfl Salem's Avatar
    Join Date
    Aug 2001
    Location
    The edge of the known universe
    Posts
    39,659
    You really need to post more code so we can see what you're actually doing wrong.
    If you dance barefoot on the broken glass of undefined behaviour, you've got to expect the occasional cut.
    If at first you don't succeed, try writing your phone number on the exam paper.

  6. #6
    Registered User
    Join Date
    Nov 2003
    Posts
    4
    im not doing anything wrong... my code is fine as it is... but im asking a question on what im GOING to program. i wanna store linked lists in a file... im wondering how i would go about doing that.

  7. #7
    carry on JaWiB's Avatar
    Join Date
    Feb 2003
    Location
    Seattle, WA
    Posts
    1,972
    actually... what IM really asking is... if i have a pointer to an object in my class and use the new keyword w/ it... and save it using write... does the data the pointer points to carry over to the file so that i can read it if i know the filesize (it could be NULL)?
    The reason Salem asked for code is because that does not make things very clear...

    What kind of data do you mean? It depends how you write it to the file...You could write the length of the file to the top and then whatever you saved comes after it.
    "Think not but that I know these things; or think
    I know them not: not therefore am I short
    Of knowing what I ought."
    -John Milton, Paradise Regained (1671)

    "Work hard and it might happen."
    -XSquared

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Programmatically creating nodes in a treeview problem
    By DanFraser in forum C# Programming
    Replies: 2
    Last Post: 10-12-2006, 02:41 PM
  2. interchange nodes in a linked list
    By Gustavo in forum C++ Programming
    Replies: 0
    Last Post: 10-26-2004, 07:14 PM
  3. Binary Search Trees Part III
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 16
    Last Post: 10-02-2004, 03:00 PM
  4. Request for comments
    By Prelude in forum A Brief History of Cprogramming.com
    Replies: 15
    Last Post: 01-02-2004, 10:33 AM
  5. counting nodes
    By sballew in forum C Programming
    Replies: 8
    Last Post: 10-27-2001, 08:03 PM