Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win


Linking Linked List To Hard Disk

Posted on 2006-07-19
Medium Priority
Last Modified: 2008-03-06
A simple linked list--

struct node{
int data;
node *next;

Generally when we create LL it gets created in RAM , what if I want to store it hard disk so that I can add / delete more nodes to it.

Question by:sinha_anshul26
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 3

Assisted Solution

sin_ earned 120 total points
ID: 17140890

Since it doesn't make any sense to store the pointers in the hard disk, you can store the data of the linked list into the hard disk by writing method like:

void makePersistent(NODE* root)
   // get each element and store the values in some file.

NODE* getPersistentList()
   //Read from the file.
   //create the link list and associated next ptrs.
   //return it.

The bottom line is, you store the data of the linked list, not the ptrs.

Author Comment

ID: 17143413
Hi Sin_
Just to confirm I got it right...
you  mean to say,(In other words) that there is no way that we can store data at a specific location of the Hard disk (using pointers)?

I read somewhere that OS does this to manage files using FAT file system

Accepted Solution

manish_regmi earned 80 total points
ID: 17143899
In Fat it is not pointers of address but the pointers of block.

for eg. if a file occupies four blocks in block 3 5 6 9,

fat 3 points to 5 points to 6 points to 9.
it means a 32 bit fat value has block number 5.

No there is no way you can store pointers in disk. In virtual memory system you get different address each time you run (esp in dynamically allocated memory).

Manish Regmi
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!


Expert Comment

ID: 17144178
That's right Anshu! Compiler generates the virtual memory addresses, which  are mapped to a physical page address by MMU while running the application. Therefore, everytime you run the application, you will find that your pointer is pointing to a different address.

Just imagine if you store this address; it may be a garbage next time. Persistence mechanism works by storing the content; you can reconstruct the data structure while reading it back.

Hope it helps.


Author Comment

ID: 17145400
>>Hope it helps
It Helped alot ...thank you both of you

Author Comment

ID: 17145443
Oh !! I choose the other way round sin_ 's  answer should be  Accepted and manish's assisted.
But any way thank you both for  helping


Expert Comment

ID: 17147130
Not a problem! I too didn't know anything about FAT ptrs :)


Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Errors will happen. It is a fact of life for the programmer. How and when errors are detected have a great impact on quality and cost of a product. It is better to detect errors at compile time, when possible and practical. Errors that make their wa…
Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.
Suggested Courses

604 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question