Click here to Skip to main content
15,884,353 members
Please Sign up or sign in to vote.
1.70/5 (4 votes)
See more:
I have been working on this project that displays a binary tree in its real shape and to to do
that I am trying to copy the entire tree into a spacial liked list where i keep information about each node its value ,is it a leave or not ?,what is its level ..in order to print it conveniently
but the problem is that i cant copy the value of a node into the liked list's node
i tried to use another variable but it just wont work
here is a sample of the code :
C
void const_llc_arbre(noeud *racine,maillon**tete,int *cpt,maillon **q)
{
                 maillon *p;(node)(the node of the linked list)
                 allouer(&p);
                 int valeur;/** its in french !**/(value)
                 valeur=racine->info;(node->value)
                 p->val=valeur;
                 p->suiv=NULL;
                 p->niv=profondeur(racine);(the level of the node)
                if(*cpt==0){*tete=p;}(head of liked list)
                else
                {
                                (*q)->suiv=p;(next)
                }
                *q=p;
                (*cpt)++;
                const_llc_arbre(racine->fd,&(*tete),&(*cpt),&(*q));(right son)
                const_llc_arbre(racine->fg,&(*tete),&(*cpt),&(*q));(left son)
}
Posted
Updated 6-May-14 20:38pm
v2
Comments
KarstenK 7-May-14 3:31am    
I didnt get the problem. Ensure that the target isnt only a pointer but real hard allocated memory.
Legor 7-May-14 3:44am    
Can you improve your question abit pls? especially how your types are defined (maillon, noeud).
leon de boer 7-May-14 4:44am    
As per the others have said the minimum we need is the definition of the structures maillon and noeud.

The procedure allouer which takes a pointer to a maillon structure and does something to it.
The procedure profondeur which takes a pointer to noeud and returns a level of a node apparently.

Without those I doubt anyone can help you
[no name] 21-May-14 11:44am    
Are you programming in French?
"maillon" means "link".
"alloeur" means "allocate".

maillon *p;(node)(the node of the linked list) - Does this line compile?

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900