List of a List in C -
I'm trying to allocate the list of pointers to the pointers of the strontectors in which the list of strokes in each of the following definitions With:
structure node {char * text; Structure node * next; };
I have also been typed:
typedef struct node node;
I am creating a list of nodes by declaring each list as follows:
node ** list; List = (strip node **) malloc (size (structure node *) * arraySize); On each node of list
, I will have another list that I am composing as follows:
list [i] = MOLOK (size (structure node *) * sub aerraise);
I have many questions:
- Is this the right implementation for such a problem?
- I
data member of the text of the first node of each list in the big list If my question is unclear please tell me this topic But my confusion is difficult to write in my words properly.
Assuming your memory is allocated and filled correctly, you Through the text
node * array:
within the list [i] each node *
data member of the first node of the array> - & gt; Text
However, to answer your question about the implementation of the correctness, it is not really that you probably want to do this:
Struct node ** list; List = (strip node **) calloke (psychograph (structure node *) * array); For (int i = 0; i
This creates an node **
array (which is called list
, because you wanted to call it, but I will call it something else indicates that this is an array of node
- based link list), then instantiates a block of memory for each head node
So that list
is valid valid node *
s and you can start working with them.
When you add everyone from your link list, then you do something like this (at the end of this attachment, if you want sorted data, etc.) then summarize the values based on comparison Depending on you to apply.):
int i = index_where_you_want_to_insert; Structure node * currNode = list [i]; Structure node * Reduction = (Structure node *) Molec (Psychof (Structure node)); NewNode-> Text = ""; // or whatever newNode-> gt; Next = Want to start with the tap; While (currNode-> Next! = NULL) {currNode = currNode-> gt; next; } CurrNode-> Next = newnode;
It can also help you with using typedef
with written lists.
If I have made any syntax or meaning errors, my code, I apologize, since I wrote something, then it was a while and I used to write struct
s I welcome improvements.
Comments
Post a Comment