C语言 关于链表 函数如何通过参数传递返回一个单向链表
C语言 关于链表 函数如何通过参数传递返回一个单向链表
日期:2017-10-14 13:29:33 人气:1
只需要把函数返回值定义为链表节点的指针类型即可。
以下为实例代码。
#include #include struct node{int v;struct node *next;};struct node * make_head(void)//函数功能,返回一个链表的头节点{struct node *ret;ret = malloc(sizeof(struct node));//申请一个头节点空间,ret->next = NULL;return ret;/