![]() |
|
#11
|
|||
|
|||
Re: Link List In CI try to malloc memory for several node. After mallacoation, i want formed a list depends on what user input.
What is the correct method of memory management for linked list ? Quote:
I not understand what u say here. A billion thanks for oyur help. |
|||
|
#12
|
|||
|
|||
Re: Link List In CQuote:
E.g. : http://cslibrary.stanford.edu/103/ explains it (download and read the pdf) |
|
#13
|
|||
|
|||
Re: Link List In CI have read this articles before but i do see any clue from there and what is the difference ?
My idea is like this. Code:
|
|
#14
|
|||
|
|||
Re: Link List In CMy latest progam is below :
CPP / C++ / C Code:
There are some logic error there. My idea is like this : 1. create first node called newNode where head point to it; 2. create another node name thirdNode point by newnOde->next; 3. after create certain amount of thirdnode. I only have two node which length prove it. How to solve this problem ? Another problem is i want declare a pointer to point to first node and traversal the node and print its content. Should i use ptr to ptr or something else ? A billion thanks for your help. |
|
#15
|
|||
|
|||
Re: Link List In CQuote:
This is essentially correct, but it isn't a "completion" of the thoughts that go into understanding why one creates a LIST structure and a NODE structure as separate entities. Part of the reason, and one of the most important, is so that "list functions" can be easily separated from "node functions" so that the API for dealing with lists and nodes are more organized and managed. Here is an example of the differences between LIST functions and NODE functions. CPP / C++ / C Code:
Most of the "work" that we do to nodes in a list are "list functions," and work on some set of the nodes contained in the list or nodes that are inserted or removed from the list. This is an abbreviated set of list/node functions. There are many others. There are those who feel compelled to write API that takes LIST** and NODE**, but these are very rarely necessary and tend to over-complicate the ease of understanding the code by novices. :davis: |
|
#16
|
|||
|
|||
Re: Link List In CCPP / C++ / C Code:
I think i understand better than before. CPP / C++ / C Code:
1. First, allocate memory for a node, reutn back to main. CPP / C++ / C Code:
CPP / C++ / C Code:
3. After that, u pass those parameter to list function, and let th end list to tail->next point to newNode; By the way, why u return integer. Is it to indicate success to form a list ? Sorry for my stupidity. I very happy what u told me right now. As every IT professional know, Linux guys is better than someone else. I very admire davis. Davis is my star. In contrast, how about my idea. Is it a bad idea ? Post 14. Imagine struct List contain a struct node *head ptr. ptr | firstnode, then call again the function to allocate memory for second node, pass both list and node to append function. Am i correct ? I feel this is much more easy when separate the problem(break into small pieces). A billion thanks for your help. A billion thanks for your help. |
|
#17
|
|||
|
|||
Re: Link List In CMy latest link List program :
CPP / C++ / C Code:
Header File CPP / C++ / C Code:
How to initialize struct node*head in struc LList ? CPP / C++ / C Code:
Morevoer, i have idea where InsertBehind function pass LLIst and also a node. I can attach first node but not the second. I want declare a pointer(current) then travesal until end of list the what pointed by travesal next point to new node. Quote:
Quote:
This statement is never be execute because i store other address. I want declare a pointer current then point to what head pointed to. I think i have did that. How to do this ? A billion thanks for your help. |
|
#18
|
|||
|
|||
Re: Link List In CCPP / C++ / C Code:
When i second call insertBehind, then insert a new value to the node all the node become second node value already, |
|
#19
|
|||
|
|||
Re: Link List In CCPP / C++ / C Code:
I know why you want to return the pointer after memory allocation rather than using void. Even though, variable names is same but the memory addresses totally different. Therefore, you can form a link list but this. You also return List ptr where you can form a two or more list which you can differentiate at later time. A billion thanks for your help. |
|
#20
|
|||
|
|||
Re: Link List In CI want to know how to implement deallocate function because i didn't have any clue.
I not asking you all to wrote for me but at least give me some hint. CPP / C++ / C Code:
CPP / C++ / C Code:
Thanks. |
Recent GIDBlog
Accepted for Ph.D. program by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| game problem using linkedListType.h and random function | eureka360 | C++ Forum | 5 | 16-Feb-2007 11:48 |
| C++ class -- Please help | vnca_1 | C++ Forum | 3 | 14-Jun-2006 13:31 |
| [Include] Doubly-linked List | dsmith | C Programming Language | 6 | 14-Apr-2006 14:12 |
| linked list error message | Krandygrl00 | C++ Forum | 4 | 22-Jun-2005 15:13 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The