| | |
The C++ LINKED LIST
![]() |
•
•
Join Date: Jan 2006
Posts: 3
Reputation:
Solved Threads: 0
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!!!
^_^
^_^
•
•
Join Date: Dec 2005
Posts: 43
Reputation:
Solved Threads: 0
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.
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.
C++ Syntax (Toggle Plain Text)
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; } } }
![]() |
Similar Threads
- Removing an item from head of linked list (C)
- help implementing singly linked list (C++)
- How to read in a sentence and insert in to linked list? (C++)
- Linked List using pointers (C++ ADT) (C++)
- Why doesn't this remove the last node in a linked list? (C++)
- Cannot figure out how to implement linked list and rbtree for a project! (Java)
- Linked List (C++)
- help by sorting a simply linked list (C)
Other Threads in the C++ Forum
- Previous Thread: Using C++ OOP class.....
- Next Thread: Creating data packets?
| Thread Tools | Search this Thread |
api array asterisks based binary bitmap c++ c/c++ char class classes code coding compile console conversion count delete deploy desktop developer directshow dissertationtopic dll download dynamic dynamiccharacterarray email encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp homeworkhelper iamthwee ifstream input int integer interest java knowledge languagerosettastone lib linkedlist linker loop looping loops map math matrix memory msuhangman multiple news node nodes objects output pointer polynomial problem program programming project python random read recursion reference rpg space stop string strings temperature template test text text-file tree url variable vector video warcraft3 win32 windows winsock wordfrequency wxwidgets






