Re: how this works ?
- From: "Default User" <defaultuserbr@xxxxxxxxx>
- Date: 5 Apr 2008 07:19:03 GMT
lector wrote:
void create_link_list(node *root, int n)
{
node *p, *prev;
int i;
for(i=0; i<n; i++)
{
p = malloc(sizeof(node));
p->next = NULL;
printf("Enter data\n");
scanf("%d", &p->data);
if(root == NULL)
{
root = p;
prev = root;
}
else
{
prev->next = p;
prev = p;
}
}
}
The program compile successfuly and I could link all the obj files
without any errors or warnings. When I execute the
application(ll.exe), I can input all the numbers but the link list is
not printed. I think the problem lies in the fact that the link list
has been created but the copy of updated pointer to the root node is
not available as it got destroyed once the create routine terminated.
I didn't get destroyed, it got lost. See the FAQs:
<http://c-faq.com/ptrs/passptrinit.html>
Brian
.
- Follow-Ups:
- Re: how this works ?
- From: lector
- Re: how this works ?
- References:
- how this works ?
- From: lector
- Re: how this works ?
- From: Lew Pitcher
- Re: how this works ?
- From: lector
- how this works ?
- Prev by Date: Re: Not a number problem
- Next by Date: New Air Force 1, Jordan Combination,AF1 + J3,AF1 + J4,,AF1 + J5,AF1+ J12,AF1 + J23,J10 + J12(all Price 30USD) - Sunrise East Asia Sporting Goods Co.,LTD
- Previous by thread: Re: how this works ?
- Next by thread: Re: how this works ?
- Index(es):
Relevant Pages
|
Loading