单链表的增删改查_代码篇
#include<stdio.h>
#include<stdlib.h>
#define N 8
struct LNode {
char data;
struct LNode* next;
}node;
LNode* creatlist(char* a)
{
LNode *head, *p1, *p2; int n = 1, p;
head = (struct LNode*)malloc(sizeof(struct LNode));
p1 = (struct LNode*)malloc(sizeof(struct LNode));
if (p1) {
for (p = 0; p < N; p++){
p1->data = a[p];
if (p == 0)
head->next = p1;
p2 = p1;
p1 = (struct LNode*)malloc(sizeof(struct LNode));
p2->next = p1;
}
p2->next = NULL;
free(p1);
return head;
}
}
void outlist(LNode* h)
{
LNode* p; p = h->next;
if (p == NULL) printf("\nThe list is NULL!\n");
else