how do i label a linked list?

Reply

Join Date: Nov 2006
Posts: 224
Reputation: bugmenot is an unknown quantity at this point 
Solved Threads: 31
bugmenot bugmenot is offline Offline
Posting Whiz in Training

how do i label a linked list?

 
0
  #1
Dec 7th, 2007
Hi, I have a linked list which I created in a function? I want to allow the user to enter a name for the linked list, and then after he/she can display the list by typing in the title. This is part of my code

  1. struct llistt{
  2. char str[100]; // where the strings will be kept
  3. struct llistt *next
  4. struct llistt *prev
  5. }
  6.  
  7. typedef struct llistt node
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 7,660
Reputation: Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute Narue has a reputation beyond repute 
Solved Threads: 724
Team Colleague
Narue's Avatar
Narue Narue is offline Offline
Code Goddess

Re: how do i label a linked list?

 
0
  #2
Dec 7th, 2007
Right now your list consists only of nodes. If you want data that applies to the list as a whole, you should create a new structure that contains a list as well as that data:
  1. struct node {
  2. char str[100]; // where the strings will be kept
  3. struct node *next
  4. struct node *prev
  5. };
  6.  
  7. struct list {
  8. char name[100];
  9. struct node *head;
  10. };
  11.  
  12. typedef struct node node;
  13. typedef struct list list;
Then you use it the same way, just instead of arbitrary pointers for the head of the list, you store it in a list object.
I'm here to prove you wrong.
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC