用C语言编写一串代码,判断头结点单链表是否为空表
时间: 2023-05-28 11:06:17 浏览: 91
C语言写的带有头结点的链表
```
#include <stdio.h>
#include <stdlib.h>
typedef struct Node {
int data;
struct Node *next;
} Node;
int isEmpty(Node *head) {
if (head->next == NULL) {
return 1;
} else {
return 0;
}
}
int main() {
Node *head = (Node*)malloc(sizeof(Node));
head->next = NULL;
if (isEmpty(head)) {
printf("The list is empty.\n");
} else {
printf("The list is not empty.\n");
}
return 0;
}
```
阅读全文