链表程序不知道哪里错了
error C2275: 'pnode' : illegal use of this type as an expression#include<stdio.h>
#include<malloc.h>
#include<stdlib.h>
typedef struct node
{
int data;
struct node *next;
}node,*pnode;
pnode a(void);
void b(pnode phand);
int main(void)
{
pnode phand=NULL;
phand=a();
b(phand);
return 0;
}
pnode a(void)
{
int len;
int i;
int val;
pnode phand=(pnode)malloc(sizeof(node));
if(phand==NULL)
{
printf("分配失败,程序终止!");
exit(-1);
}
pnode ptail=phand;
ptail->next=NULL;
printf("请输入所需要的长度:");
scanf("%d",&len);
for(i=0;i<len;i++)
{
printf("请输入第%d个值:",i+1);
scanf("%d",&val);
pnode pnew=(pnode)malloc(sizeof(node));
if(pnew==NULL)
{
printf("分配失败,程序终止!");
exit(-1);
}
pnew->data=val;
ptail->next=pnew;
pnew->next=NULL;
ptail=pnew;
}
}
void b(pnode phand)
{
pnode p=phand->next;
while(p!=NULL)
{
printf("%d",p->data);
p=p->next;
}
}
[此贴子已经被作者于2017-10-21 13:23编辑过]