C语言数据结构1
#include#include
#include
typedef struct Node
{
int data;
struct node * pnext;
}node,*pnode;
pnode creat list(void);
traver list(phead);
int main(void)
{
pnode phead=null;
phead=creat list();
traver list(phead);
return 0;
}
pnode creat list(void)
{
pnode ptail=phead;
ptail->pnext=null;
int len;
int val;
pnode phead=(pnode)malloc(sizeof(node));
if(NULL==phead)
{
printf("分配失败");
exit(-1);
}
printf("请输入节点个数len=");
scanf("%d",&len);
else
printf("分配成功");
for(int i=0;i<LEN;I++)
{
printf("第%d个的值:",i+1);
scanf("%d",&val);
pnode pnew=(pnode)malloc(node);
if(null==pnew)
{
printf("分配失败");
exit(-1);
}
else
{
printf("分配成功");
}
pnew->data=val;
ptail->pnext=pnew;
pnew->pnext=null;
ptail=pnew;
}
return phead;
}
traver list(pnode list)
{
pnode p=phead->pnext;
while(NULL!=p)
{
printf("%d",pnew->data);
p=p->pnext;
}
}
请解释一下traver list (pnode list) 函数 中 p=p->pnext执行过程,然后,pnode p=phead->pnext与pnode p->pnext
=phead->pnext有区别吗?