一个关于链表的C语言程序求解

#include<stdio.h>
#include<conio.h>
struct mynew
{
int a;
struct mynew *p;
};

struct mynew *creat(int n)
{
struct mynew *head,*pf,*pb;
int i;
for(i=0;i<n;i++)
{
pb=(struct mynew *)malloc(sizeof(struct mynew));
printf("please input a number:");
scnaf("%d",&pb->a);
if(i==0) pf=head=pb;
else pf->p=pb;
pb->p=NULL;
pf=pb;
}
return(head);
}

void main()
{
int n;
struct mynew *ptr;
printf("please input how many structs do your want to creat:");
scanf("%d",&n);
ptr=*creat(n);
for(;;)
{
printf("%d",ptr->a);
ptr++;
if(ptr->p==NULL) break;
}
getch();
}
RT:一个创建链表,输入数据,然后显示出来的链表,可为何编译到"ptr=*creat(n);"这一句的时候就出错了?系统说是incompatible types in assignment……不知道哪里不匹配了……求解,谢谢了~~

"ptr=*creat(n);"
这里出错了,函数调用你还加*做什么呢?
直接函数名就可以了。
scnaf("%d",&pb->a); 这里也拼写出错了
温馨提示:答案为网友推荐,仅供参考
第1个回答  2012-03-22
qff
相似回答