The list is C language learning more difficult part of the content, the following example shows the creation of a linked list and from the input to assign value, I hope to be useful to everyone.
#include <stdio.h>
#include <stdlib.h>
struct link
{
int num;
struct link *next;
int main ()
{
int n,i;
struct link *head,*p;
printf ("How many numbers does you want to input:");
scanf ("%d", &n);
head= (struct link*) malloc (sizeof link);//Create Header node
struct (p= struct) link* (malloc (sizeof link));/apply for the first node
head->next=p;//chain Joint node and first node
printf ("Please input numbers:\n");
for (i=0;i<n;i++)
{
scanf ("%d", &p->num);
p->next= (struct link*) malloc (sizeof link);/Request next node
struct connect the node to the next node
p=p->next;// head->next;//because the first loop has moved the list to the end, this is where you move the list to the first node to start printing for
(i=0;i<n;i++)
{
printf ("%d", P->num) ;
p=p->next;
}
return 0;
}