Help with recursion and pointers building doubly linked list from a binary tree.
Author Message
Help with recursion and pointers building doubly linked list from a binary tree.

I am trying to build a doubly linked list from a binary tree to
eventually solve a numerical expression.  I don't understand why the
addresses don't pass from recursive call to recursive call.  The ouput
for my code looks like this:

Please enter a numerical expression to be evaluated :
To enter expression use spaces between (,),+.-,/,*  :
5 + 7
call build with ptr lft , ptr oper is +
adress of stack ptr before function call 2ff7fc2c
putting value into node, value is, 5.000000
address of new ptr, next, 2ff7fb6c
call with right, ptr oper is +
adress of stack ptr before function call 2ff7fc2c
putting value into node, value is, 7.000000
address of new ptr, next, 2ff7fb6c
putting oper into node, ptr value is +

The function I am using to create this output is as follows.

struct stackset *buildlinkstack(struct node *ptr, struct stackset
*stackptr)
{

struct stackset *tempstackptr, *newstackptr;

if ((ptr -> left) != NULL)
{
printf("call build with ptr lft , ptr oper is %c\n", ptr ->
operator);
printf("adress of stack ptr before function call %p\n",
&stackptr);
printf("call with right, ptr oper is %c\n",ptr -> operator);
printf("adress of stack ptr before function call %p\n",
&stackptr);
printf("putting oper into node, ptr value is %c\n", ptr ->
operator);
tempstackptr = stackptr;
stackptr -> value = ptr -> value;
stackptr -> operator = ptr -> operator;
stackptr -> next = (struct stackset *)malloc(sizeof(struct
stackset));
newstackptr = stackptr -> next;
newstackptr -> previous = tempstackptr;
newstackptr -> next = NULL;
return newstackptr;
}
else
{
printf("putting value into node, value is, %f \n", ptr ->
value);
tempstackptr = stackptr;
stackptr -> value = ptr -> value;
stackptr -> operator = ptr -> operator;
stackptr  -> next = (struct stackset *)malloc(sizeof(struct
stackset));
newstackptr = stackptr -> next;
newstackptr -> previous = tempstackptr;
newstackptr -> next  = NULL;
printf("address of new ptr, next, %p\n", &newstackptr);
return newstackptr;
}

Quote:
}

The call I am making to the function is as follows.

begstackptr = (struct stackset *)malloc(sizeof(struct stackset));
begstackptr -> next = NULL;
begstackptr -> previous = NULL;
begstackptr -> value = 0;
begstackptr -> operator = 'n';

Please respond if you have a suggestion to why the addresses are not
being passed to the various calls. My email address is

understand the way variable are passed function to function.  I thought
that if an address was passed changes would be reflected in the
location that they were coming from.

Sat, 18 Jan 1997 10:04:34 GMT
Help with recursion and pointers building doubly linked list from a binary tree.
I am trying to build a doubly linked list from a binary tree to
eventually solve a numerical expression.  I don't understand why the
addresses don't pass from recursive call to recursive call.  The ouput
for my code looks like this:

Please enter a numerical expression to be evaluated :
To enter expression use spaces between (,),+.-,/,*  :
5 + 7
call build with ptr lft , ptr oper is +
adress of stack ptr before function call 2ff7fc2c
putting value into node, value is, 5.000000
address of new ptr, next, 2ff7fb6c
call with right, ptr oper is +
adress of stack ptr before function call 2ff7fc2c
putting value into node, value is, 7.000000
address of new ptr, next, 2ff7fb6c
putting oper into node, ptr value is +

The function I am using to create this output is as follows.

struct stackset *buildlinkstack(struct node *ptr, struct stackset
*stackptr)
{

struct stackset *tempstackptr, *newstackptr;

if ((ptr -> left) != NULL)
{
printf("call build with ptr lft , ptr oper is %c\n", ptr ->
operator);
printf("adress of stack ptr before function call %p\n",
&stackptr);
printf("call with right, ptr oper is %c\n",ptr -> operator);
printf("adress of stack ptr before function call %p\n",
&stackptr);
printf("putting oper into node, ptr value is %c\n", ptr ->
operator);
tempstackptr = stackptr;
stackptr -> value = ptr -> value;
stackptr -> operator = ptr -> operator;
stackptr -> next = (struct stackset *)malloc(sizeof(struct
stackset));
newstackptr = stackptr -> next;
newstackptr -> previous = tempstackptr;
newstackptr -> next = NULL;
return newstackptr;
}
else
{
printf("putting value into node, value is, %f \n", ptr ->
value);
tempstackptr = stackptr;
stackptr -> value = ptr -> value;
stackptr -> operator = ptr -> operator;
stackptr  -> next = (struct stackset *)malloc(sizeof(struct
stackset));
newstackptr = stackptr -> next;
newstackptr -> previous = tempstackptr;
newstackptr -> next  = NULL;
printf("address of new ptr, next, %p\n", &newstackptr);
return newstackptr;
}

Quote:
}

The call I am making to the function is as follows.

begstackptr = (struct stackset *)malloc(sizeof(struct stackset));
begstackptr -> next = NULL;
begstackptr -> previous = NULL;
begstackptr -> value = 0;
begstackptr -> operator = 'n';

Please respond if you have a suggestion to why the addresses are not
being passed to the various calls. My email address is

understand the way variable are passed function to function.  I thought
that if an address was passed changes would be reflected in the
location that they were coming from.

Sat, 18 Jan 1997 07:49:46 GMT
Help with recursion and pointers building doubly linked list from a binary tree.
I am trying to build a doubly linked list from a binary tree to
eventually solve a numerical expression.  I don't understand why the
addresses don't pass from recursive call to recursive call.  The ouput
for my code looks like this:

Please enter a numerical expression to be evaluated :
To enter expression use spaces between (,),+.-,/,*  :
5 + 7
call build with ptr lft , ptr oper is +
adress of stack ptr before function call 2ff7fc2c
putting value into node, value is, 5.000000
address of new ptr, next, 2ff7fb6c
call with right, ptr oper is +
adress of stack ptr before function call 2ff7fc2c
putting value into node, value is, 7.000000
address of new ptr, next, 2ff7fb6c
putting oper into node, ptr value is +

The function I am using to create this output is as follows.

struct stackset *buildlinkstack(struct node *ptr, struct stackset
*stackptr)
{

struct stackset *tempstackptr, *newstackptr;

if ((ptr -> left) != NULL)
{
printf("call build with ptr lft , ptr oper is %c\n", ptr ->
operator);
printf("adress of stack ptr before function call %p\n",
&stackptr);
printf("call with right, ptr oper is %c\n",ptr -> operator);
printf("adress of stack ptr before function call %p\n",
&stackptr);
printf("putting oper into node, ptr value is %c\n", ptr ->
operator);
tempstackptr = stackptr;
stackptr -> value = ptr -> value;
stackptr -> operator = ptr -> operator;
stackptr -> next = (struct stackset *)malloc(sizeof(struct
stackset));
newstackptr = stackptr -> next;
newstackptr -> previous = tempstackptr;
newstackptr -> next = NULL;
return newstackptr;
}
else
{
printf("putting value into node, value is, %f \n", ptr ->
value);
tempstackptr = stackptr;
stackptr -> value = ptr -> value;
stackptr -> operator = ptr -> operator;
stackptr  -> next = (struct stackset *)malloc(sizeof(struct
stackset));
newstackptr = stackptr -> next;
newstackptr -> previous = tempstackptr;
newstackptr -> next  = NULL;
printf("address of new ptr, next, %p\n", &newstackptr);
return newstackptr;
}

Quote:
}

The call I am making to the function is as follows.

begstackptr = (struct stackset *)malloc(sizeof(struct stackset));
begstackptr -> next = NULL;
begstackptr -> previous = NULL;
begstackptr -> value = 0;
begstackptr -> operator = 'n';

Please respond if you have a suggestion to why the addresses are not
being passed to the various calls. My email address is

understand the way variable are passed function to function.  I thought
that if an address was passed changes would be reflected in the
location that they were coming from.

Sat, 18 Jan 1997 11:46:54 GMT
Help with recursion and pointers building doubly linked list from a binary tree.
I am trying to build a doubly linked list from a binary tree to
eventually solve a numerical expression.  I don't understand why the
addresses don't pass from recursive call to recursive call.  The ouput
for my code looks like this:

Please enter a numerical expression to be evaluated :
To enter expression use spaces between (,),+.-,/,*  :
5 + 7
call build with ptr lft , ptr oper is +
adress of stack ptr before function call 2ff7fc2c
putting value into node, value is, 5.000000
address of new ptr, next, 2ff7fb6c
call with right, ptr oper is +
adress of stack ptr before function call 2ff7fc2c
putting value into node, value is, 7.000000
address of new ptr, next, 2ff7fb6c
putting oper into node, ptr value is +

The function I am using to create this output is as follows.

struct stackset *buildlinkstack(struct node *ptr, struct stackset
*stackptr)
{

struct stackset *tempstackptr, *newstackptr;

if ((ptr -> left) != NULL)
{
printf("call build with ptr lft , ptr oper is %c\n", ptr ->
operator);
printf("adress of stack ptr before function call %p\n",
&stackptr);
printf("call with right, ptr oper is %c\n",ptr -> operator);
printf("adress of stack ptr before function call %p\n",
&stackptr);
printf("putting oper into node, ptr value is %c\n", ptr ->
operator);
tempstackptr = stackptr;
stackptr -> value = ptr -> value;
stackptr -> operator = ptr -> operator;
stackptr -> next = (struct stackset *)malloc(sizeof(struct
stackset));
newstackptr = stackptr -> next;
newstackptr -> previous = tempstackptr;
newstackptr -> next = NULL;
return newstackptr;
}
else
{
printf("putting value into node, value is, %f \n", ptr ->
value);
tempstackptr = stackptr;
stackptr -> value = ptr -> value;
stackptr -> operator = ptr -> operator;
stackptr  -> next = (struct stackset *)malloc(sizeof(struct
stackset));
newstackptr = stackptr -> next;
newstackptr -> previous = tempstackptr;
newstackptr -> next  = NULL;
printf("address of new ptr, next, %p\n", &newstackptr);
return newstackptr;
}

Quote:
}

The call I am making to the function is as follows.

begstackptr = (struct stackset *)malloc(sizeof(struct stackset));
begstackptr -> next = NULL;
begstackptr -> previous = NULL;
begstackptr -> value = 0;
begstackptr -> operator = 'n';

Please respond if you have a suggestion to why the addresses are not
being passed to the various calls. My email address is

understand the way variable are passed function to function.  I thought
that if an address was passed changes would be reflected in the
location that they were coming from.

Sat, 18 Jan 1997 22:39:33 GMT
Help with recursion and pointers building doubly linked list from a binary tree.
I am trying to build a doubly linked list from a binary tree to
eventually solve a numerical expression.  I don't understand why the
addresses don't pass from recursive call to recursive call.  The ouput
for my code looks like this:

Please enter a numerical expression to be evaluated :
To enter expression use spaces between (,),+.-,/,*  :
5 + 7
call build with ptr lft , ptr oper is +
adress of stack ptr before function call 2ff7fc2c
putting value into node, value is, 5.000000
address of new ptr, next, 2ff7fb6c
call with right, ptr oper is +
adress of stack ptr before function call 2ff7fc2c
putting value into node, value is, 7.000000
address of new ptr, next, 2ff7fb6c
putting oper into node, ptr value is +

The function I am using to create this output is as follows.

struct stackset *buildlinkstack(struct node *ptr, struct stackset
*stackptr)
{

struct stackset *tempstackptr, *newstackptr;

if ((ptr -> left) != NULL)
{
printf("call build with ptr lft , ptr oper is %c\n", ptr ->
operator);
printf("adress of stack ptr before function call %p\n",
&stackptr);
printf("call with right, ptr oper is %c\n",ptr -> operator);
printf("adress of stack ptr before function call %p\n",
&stackptr);
printf("putting oper into node, ptr value is %c\n", ptr ->
operator);
tempstackptr = stackptr;
stackptr -> value = ptr -> value;
stackptr -> operator = ptr -> operator;
stackptr -> next = (struct stackset *)malloc(sizeof(struct
stackset));
newstackptr = stackptr -> next;
newstackptr -> previous = tempstackptr;
newstackptr -> next = NULL;
return newstackptr;
}
else
{
printf("putting value into node, value is, %f \n", ptr ->
value);
tempstackptr = stackptr;
stackptr -> value = ptr -> value;
stackptr -> operator = ptr -> operator;
stackptr  -> next = (struct stackset *)malloc(sizeof(struct
stackset));
newstackptr = stackptr -> next;
newstackptr -> previous = tempstackptr;
newstackptr -> next  = NULL;
printf("address of new ptr, next, %p\n", &newstackptr);
return newstackptr;
}

Quote:
}

The call I am making to the function is as follows.

begstackptr = (struct stackset *)malloc(sizeof(struct stackset));
begstackptr -> next = NULL;
begstackptr -> previous = NULL;
begstackptr -> value = 0;
begstackptr -> operator = 'n';

Please respond if you have a suggestion to why the addresses are not
being passed to the various calls. My email address is

understand the way variable are passed function to function.  I thought
that if an address was passed changes would be reflected in the
location that they were coming from.

Sat, 18 Jan 1997 22:41:31 GMT
Help with recursion and pointers building doubly linked list from a binary tree.
I am trying to build a doubly linked list from a binary tree to
eventually solve a numerical expression.  I don't understand why the
addresses don't pass from recursive call to recursive call.  The ouput
for my code looks like this:

Please enter a numerical expression to be evaluated :
To enter expression use spaces between (,),+.-,/,*  :
5 + 7
call build with ptr lft , ptr oper is +
adress of stack ptr before function call 2ff7fc2c
putting value into node, value is, 5.000000
address of new ptr, next, 2ff7fb6c
call with right, ptr oper is +
adress of stack ptr before function call 2ff7fc2c
putting value into node, value is, 7.000000
address of new ptr, next, 2ff7fb6c
putting oper into node, ptr value is +

The function I am using to create this output is as follows.

struct stackset *buildlinkstack(struct node *ptr, struct stackset
*stackptr)
{

struct stackset *tempstackptr, *newstackptr;

if ((ptr -> left) != NULL)
{
printf("call build with ptr lft , ptr oper is %c\n", ptr ->
operator);
printf("adress of stack ptr before function call %p\n",
&stackptr);
printf("call with right, ptr oper is %c\n",ptr -> operator);
printf("adress of stack ptr before function call %p\n",
&stackptr);
printf("putting oper into node, ptr value is %c\n", ptr ->
operator);
tempstackptr = stackptr;
stackptr -> value = ptr -> value;
stackptr -> operator = ptr -> operator;
stackptr -> next = (struct stackset *)malloc(sizeof(struct
stackset));
newstackptr = stackptr -> next;
newstackptr -> previous = tempstackptr;
newstackptr -> next = NULL;
return newstackptr;
}
else
{
printf("putting value into node, value is, %f \n", ptr ->
value);
tempstackptr = stackptr;
stackptr -> value = ptr -> value;
stackptr -> operator = ptr -> operator;
stackptr  -> next = (struct stackset *)malloc(sizeof(struct
stackset));
newstackptr = stackptr -> next;
newstackptr -> previous = tempstackptr;
newstackptr -> next  = NULL;
printf("address of new ptr, next, %p\n", &newstackptr);
return newstackptr;
}

Quote:
}

The call I am making to the function is as follows.

begstackptr = (struct stackset *)malloc(sizeof(struct stackset));
begstackptr -> next = NULL;
begstackptr -> previous = NULL;
begstackptr -> value = 0;
begstackptr -> operator = 'n';

Please respond if you have a suggestion to why the addresses are not
being passed to the various calls. My email address is

understand the way variable are passed function to function.  I thought
that if an address was passed changes would be reflected in the
location that they were coming from.

Sun, 19 Jan 1997 00:44:40 GMT

 Page 1 of 1 [ 6 post ]

Relevant Pages