Adding a linked list onto a file

HI

i am working on a small mini project.

I have used a linked list to create a small database.

Now i want to save it onto a file.

But as i am using pointer how can i save it onto a file.

Comments

  • : HI
    :
    : i am working on a small mini project.
    :
    : I have used a linked list to create a small database.
    :
    : Now i want to save it onto a file.
    :
    : But as i am using pointer how can i save it onto a file.
    :

    My first thought is converting the pointers to indexes.
    So basically, you store the first node in the file and give it's pointer an index of 1. Then you take the original pointer value to get to the next node. You store this node to the file at index = 2 and give it's pointer value that index. Then you trace it's original pointer value to the next item and so on until you reach the last item. If you use 1-bases indexing, you can use an inex of 0 to signify the end of the list.


    Best Regards,
    Richard

    The way I see it... Well, it's all pretty blurry
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

In this Discussion