User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the C++ section within the Software Development category of DaniWeb, a massive community of 402,446 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,998 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our C++ advertiser: Programming Forums
Views: 8885 | Replies: 3
Reply
Join Date: Jan 2006
Posts: 3
Reputation: Twins_effect is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Twins_effect Twins_effect is offline Offline
Newbie Poster

Help The C++ LINKED LIST

  #1  
Jan 13th, 2006
hey guys, im a new guy here in the forum and im also an IT student who gets into C++ troubles most of the time, but enough about that... i just wanna ask if anyone can help me in my linked list problem, i think its about pointers and address. like a->link, well thats what it looked like. Problem is i dont understand a thing and my prof wont even give me an example, i dont even get the slightest idea of what's it all about and i dont know where to start, SO CAN ANYONE PLS SHOW ME AN EXAMPLE,even just the basic ones THANKS!!!
^_^
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Aug 2005
Posts: 4,711
Reputation: iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light iamthwee is a glorious beacon of light 
Rep Power: 17
Solved Threads: 309
iamthwee's Avatar
iamthwee iamthwee is offline Offline
Industrious Poster

Re: The C++ LINKED LIST

  #2  
Jan 13th, 2006
try google + "linked lists"
Member of: F-ugly code club

Join today don't delay!
Reply With Quote  
Join Date: Dec 2005
Location: Pleasanton, CA
Posts: 43
Reputation: Nedals is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 0
Nedals Nedals is offline Offline
Light Poster

Re: The C++ LINKED LIST

  #3  
Jan 14th, 2006
Linked list are typically used to work with data structures.
Access to items in the list is controlled by pointers.

This is a very simple example to construct a linked list. You will need to do a lot more reading to use them correctly.

One thing to remember:
You must delete all the list items when exiting the program otherwise you will create a memory leak.
struct dataRec {
  type     data;
  dataRec  *next;
}

dataRec *prList = NULL;  // the list anchor

function addRecord(dataRec *prList) {
  dataRec *temp = new dataRec;  // create a new record to add to list
  temp->data = whatever;
  temp->next = NULL;

  // Now add this record to the end of the list
  dataRec *curr = prList;	
  if (curr == NULL) {  // the list is empty
    prList = temp;  // prList, the anchor, now points to the first record
  }
  else {
    if (curr->next == NULL) { // last record in list
      curr->next = temp;  // add temp to end of list
    }
    else {  // move up the list until the last entry
      curr = curr->next;
    }
  }
}
Reply With Quote  
Join Date: Jan 2006
Posts: 3
Reputation: Twins_effect is an unknown quantity at this point 
Rep Power: 0
Solved Threads: 0
Twins_effect Twins_effect is offline Offline
Newbie Poster

Re: The C++ LINKED LIST

  #4  
Jan 15th, 2006
thanks, i really appreciate it! i think i'll do some head crackinh for awhile to master this ^^
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

DaniWeb C++ Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Similar Threads
Other Threads in the C++ Forum

All times are GMT -4. The time now is 2:55 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC