C语言链表中head==NULL指的是指针域为空还是什么?

2025-06-22 23:26:41
推荐回答(1个)
回答1:

表示整个链表为空,没有任何成员元素。

head等于null,表示head无任何数据,没有数据和next指针;

head == null和head->next = null是不等价的,后者表示存在head数据,但链表只有head一个节点数据。 

struct Telphone /*自定义多数据域的链表*/

{

char name[20];

char address[20];

char zip[20];

char telphone[20];

struct Telphone *next; /*链表指针域设定*/

};

typedef struct Telphone TEL; //自定义

TEL *head=NULL;

head=(TEL *)malloc(sizeof(TEL));   

是否用mallo函数分配内存后head就变为了名叫head的节点了。