Recently fascinated by the C language, deliberately borrowed a book on the C language algorithm fine solution, the book has a lot of good code, learn to share to everyone.
Here are all the source code in the blog: GitHub Project address
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#define LEN sizeof (struct node)
struct node
{
int data;
struct node *next;
int main (int argc, char const *argv[]) {
struct node *p, *PL, *head;
Head = p = (struct node *) malloc (LEN);
scanf ("%d", &p->data);
/* Replace EOF into input 0 when terminating the input to the list *
/while (p->data!= 0) {
PL = p;
p = (struct node *) malloc (LEN);
scanf ("%d", &p->data);
Pl->next = P;
}
P->next = NULL;
p = head;
printf ("List number is:");
/* The pointer to the element in the list is not NULL, the elements in the cyclic output list *
/while (P->next!= NULL) {
printf ("%d\n", p->data);
p = p->next;
}
printf ("%d\n", P->data);
}
If there are deficiencies in the above code, I hope you will criticize me.