How to show the list number
I am trying to write code that show the list of two nods
I have written following code and I want help to show the list numbers.
Code:
#include<stdio.h>
struct list
{
int n;
struct list *next;
}
void main()
{
/* Both first and last are null pointer */
struct list *first = NULL;
struct list *last = NULL;
/* Allocate dyanamic memory */
first = malloc(sizeof(*first));
last = malloc(sizeof(*last));
first->n = 5; /* first pointer point data of first node*/
first-> next = last; /* first pointer point address of next node*/
last->n = 10; /* last pointer point data of last node*/
last->next = NULL; /*last pointer set as NULL pointer because there is no next node */
}
How to show the list numbers ?
Code:
struct list
{
int n;
struct list *next;
}
void main()
{
/* Both first and last are null pointer */
struct list *first = NULL;
struct list *last = NULL;
/* Allocate dyanamic memory */
first = malloc(sizeof(*first));
last = malloc(sizeof(*last));
first->n = 5; /* first pointer point data of first node*/
first-> next = last; /* first pointer point address of next node*/
last->n = 10; /* last pointer point data of last node*/
last->next = NULL; /*last pointer set as NULL pointer because there is no next node */
}