C语言链表问题,高分悬赏,请问这2哥函数怎么用,还有struct node*h = createlist()是什么意思

#include<stdio.h>
#include<stdlib.h>

struct node
{
int data;
struct node *next;
};
struct node* createlist()
{
int data;
struct node*p,*q=NULL,*h=NULL;
while(1)
{
if((data=getchar())!='\n'&&data!=32)
{
p=(struct node*)malloc(sizeof(struct node));
p->data =data;
if(h==NULL) /*the first tree*/
h=p;
else
q->next=p;
q=p;
}
else if(data=='\\')
break;
}
if(q!=NULL)
q->next =NULL;
return h;
}

int main()
{
struct node * h = createlist();

return 0;
displist();
}
int displist(struct node*h)
{
struct node*p =h;
while(p!=NULL)
{
printf("%4c",p->data);
p=p->next ;
}
}

int main()
{
struct node * h = createlist(); //这是调用创建链表函数,返回表头指针 给h
displist( h ); //这个函数调用 缺少了参数
return 0; //程序遇到Return命令就会返回函数调用者,若main中,就会返回系统,即程序退出
}
温馨提示:答案为网友推荐,仅供参考
第1个回答  2013-08-16
struct node* createlist()
这是一个函数,返回类型是struct node*,那么struct node* h = createlist();就是让h等于createlist()函数返回的指针。

main函数中的
return 0;
displist();
displist()函数这样是不会执行的,因为return 0已经表示返回了。追问

那怎么操作啊。我网上找到一个
typedef struct NodeType
{
ElemType data;
struct NodeType *next;
} NodeType,*LinkType;
这个时候 linktype是带*的
void output(LinkType head)
,为什么调用的时候就没有 * 了呢,能不能加个Q.Q,我有好多问题,分数当然不是问题

追答

可以 60 56 45324

相关了解……

你可能感兴趣的内容

本站内容来自于网友发表,不代表本站立场,仅表示其个人看法,不对其真实性、正确性、有效性作任何的担保
相关事宜请发邮件给我们
© 非常风气网