i agree with you.........the head in the function is different from what it
is in the main() as it is not global......so it doesnt get modified
thnx :)

On Sun, Jan 16, 2011 at 11:21 AM, pacific pacific <pacific4...@gmail.com>wrote:

> #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++ <avpostni...@gmail.com> 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 algogeeks@googlegroups.com.
>> To unsubscribe from this group, send email to
>> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com>
>> .
>> 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 algogeeks@googlegroups.com.
> To unsubscribe from this group, send email to
> algogeeks+unsubscr...@googlegroups.com<algogeeks%2bunsubscr...@googlegroups.com>
> .
> For more options, visit this group at
> http://groups.google.com/group/algogeeks?hl=en.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to algogeeks@googlegroups.com.
To unsubscribe from this group, send email to 
algogeeks+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to