#include <stdio.h>
#include <stdlib.h>
struct node {
int a ;
};
int insert(struct node * head )
{
struct node * temp;
temp= (struct node *) malloc(sizeof(struct node ));
printf("temp in function %d \n",temp);
head = temp;
}
int main()
{
struct node * temp;
temp= (struct node *) malloc(sizeof(struct node ));
printf(" temp before function %d\n ",temp);
insert(temp);
printf(" temp after function %d\n ",temp);
}
Output :
temp before function 167862280
temp in function 167862296
temp after function 167862280
The assignment in the function insert to the head doesn't affect in the
caller.I hope this example clears the doubt.
I suggest an implementation like this ,
struct node * insert(struct node * head , int data ) which returns the head
of the tree to the caller.
Let me know if i'm wrong anywhere.
On Sun, Jan 16, 2011 at 12:34 AM, juver++ <[email protected]> wrote:
> @above
> Of course, NO.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Algorithm Geeks" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected]<algogeeks%[email protected]>
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>
--
regards,
chinna.
--
You received this message because you are subscribed to the Google Groups
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/algogeeks?hl=en.