📄 list.c
字号:
#include "list.h"
pLink * init()
{
pLink *head;
head=(pLink *)malloc(sizeof(struct node));
strcpy(head->notifystr,"This is the start");
head->count=0;
head->next=NULL;
return head;
}
pLink * insert(pLink * head,pLink *toinsert)
{
pLink *p,*q;
q = head;
p = toinsert;
if (head==NULL)
{
head = p;p->next=NULL;
return head;
}
printf("q0 == [%s]\n",q->notifystr);
while (q->next!=NULL)
{
printf("q1 == [%s]\n",q->notifystr);
q=q->next;
printf("q1 == [%s]\n",q->notifystr);
}
q->next = p;
p->next = NULL;
printf("q == [%s]\n",q->notifystr);
printf("q->next == [%s]\n",q->next->notifystr);
return head;
}
pLink * search(pLink *head,const char *notifystr)
{
pLink *p;
p = head ->next;
while (p!=NULL)
{
if (strcmp(p->notifystr,notifystr)==0)
{
printf("Has find it!\n");
return p;
}
p=p->next;
}
printf("Can't Find it!\n");
return NULL;
}
pLink * del(pLink *head,pLink *todel)
{
pLink *p,*q;
q=head;
if (head==NULL)
{
printf("List is NULL! ");
return NULL;
}
while(strcmp(q->notifystr,todel->notifystr) != 0 && q->next != NULL)
{
p=q;q = q->next;
}
if (strcmp(q->notifystr,todel->notifystr) == 0)
{
if (q == head)
{
head = q->next;
}
p->next = q->next;
}
return head;
}
void print_list(pLink *head)
{
pLink * p;
p=head;
if (p==NULL)
{
printf("List is null!\n");
}
do
{
printf("%s\n",p->notifystr);
p = p->next;
} while (p!=NULL);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -