问个比较小白的问题:listnode *createlist(listnode *h)是什么意思? 定义函数不是 int或void+ 函数名

#include <stdio.h>
#include <stdlib.h>
struct node{
int num;
struct node *next;
};
typedef struct node listnode;
listnode *createlist(listnode *h)
{
listnode *p,*q;
int i,n;
scanf( "%d", &n );
for ( i = 0; i < n; i++ )
{
p = (listnode *)malloc(sizeof(listnode));
scanf( "%d", &p->num );
if ( i == 0 )
{
h = p;
}
else
{
q->next = p;
}
q = p;
}
q->next = NULL;
return h;
}
void traverselist(listnode *h)
{
listnode *p = h;
while( p != NULL )
{
printf( "%d ", p->num );
p = p->next;
}
printf( "\n" );
}
int main()
{
listnode *head;
head = createlist(head);
traverselist(head);
return 0;
}

第1个回答  2012-12-08
"定义函数不是 int或void+ 函数名",你这句话说的不对
定义函数是:函数返回值类型 + 函数名
你的提问中的listnode *说明函数的返回值是一个指针,这个指针指向listnode类型的结构体本回答被提问者采纳
第2个回答  2012-12-08
前面的是函数返回类型

相关了解……

你可能感兴趣的内容

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