建立了一个节点.里面的 a 是4 又在后面插入一个节点.a是56 但是打印出来只有4,没有看到56.请问是哪里出了问题.#include <stdio.h>
#include <malloc.h>
struct node
{
int a;
struct node *abc;
};
void main()
{
void ceate(int c,struct node **p);
void printflist(struct node *head);
void deletelist(struct node *h);
void insert(struct node *h,int g);
struct node *p;
int b=4;
p=NULL;
ceate(b,&p);
insert(p,56);
//deletelist(p);
printflist(p);
}
void ceate(int c,struct node **p)
{
struct node *p1;
p1=(struct node *)malloc(sizeof(struct node));
p1->a=c;
p1->abc=NULL;
*p=p1;
}
void printflist(struct node *head)
{
while(head!=NULL)
{
printf("%d",head->a);
head=head->abc;
}}void deletelist(struct node *h)
{
while(h->abc!=NULL)
{
h=h->abc;
}
free(h);
}
void insert(struct node *h,int g)
{
while(h->abc!=NULL)
{
h=h->abc;
}
h=h->abc;
h=(struct node *)malloc(sizeof(struct node));
h->a=g;
h->abc=NULL;
printf("%d",h->a); }
#include <malloc.h>
struct node
{
int a;
struct node *abc;
};
void main()
{
void ceate(int c,struct node **p);
void printflist(struct node *head);
void deletelist(struct node *h);
void insert(struct node *h,int g);
struct node *p;
int b=4;
p=NULL;
ceate(b,&p);
insert(p,56);
//deletelist(p);
printflist(p);
}
void ceate(int c,struct node **p)
{
struct node *p1;
p1=(struct node *)malloc(sizeof(struct node));
p1->a=c;
p1->abc=NULL;
*p=p1;
}
void printflist(struct node *head)
{
while(head!=NULL)
{
printf("%d",head->a);
head=head->abc;
}}void deletelist(struct node *h)
{
while(h->abc!=NULL)
{
h=h->abc;
}
free(h);
}
void insert(struct node *h,int g)
{
while(h->abc!=NULL)
{
h=h->abc;
}
h=h->abc;
h=(struct node *)malloc(sizeof(struct node));
h->a=g;
h->abc=NULL;
printf("%d",h->a); }
{
struct node *temp;
while(h->abc!=NULL)
{
h=h->abc;
}
//h=h->abc;
temp=(struct node *)malloc(sizeof(struct node));
temp->a=g;
temp->abc=h->abc;
h->abc=temp;
//h->abc=NULL;
printf("%d",h->a); }