Create 创建带头结点的单链表.c

This commit is contained in:
ViolentAyang
2022-03-08 19:23:00 +08:00
committed by GitHub
parent 317f150f12
commit 019d49f12a

View File

@@ -0,0 +1,36 @@
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>
typedef struct LNode{
int data;
struct LNode *next;
}LNode,*LinkList;
bool InitList(LinkList *L){
(*L) = (LNode*)malloc(sizeof(LNode));
if(*L==NULL){
return false;
}
(*L)->next = NULL;
return true;
}
bool Empty(LinkList L){
if(L->next==NULL){
return true;
}else{
return false;
}
}
int main(){
LinkList L;
InitList(&L);
if(Empty(L)){
printf("分配成功");
}else{
printf("分配失败");
}
return 0;
}