C
chellappa
hi
this is linked list program ,,,
this program display in reverse order...........
how to correct this error
#include <stdio.h>
struct list {
int value;
struct list *next;
};
main()
{
struct list *n1;
struct list *head =NULL;
int i;
head =n1;
for (i=0;i<10;i++)
{
n1=(struct list *)malloc(sizeof(struct list));
n1->value=i;
n1->next=head;
head=n1;
}
while( head != NULL )
{
printf("%d\n", head->value);
head = head->next;
}
}
Thank U
By
CNS
this is linked list program ,,,
this program display in reverse order...........
how to correct this error
#include <stdio.h>
struct list {
int value;
struct list *next;
};
main()
{
struct list *n1;
struct list *head =NULL;
int i;
head =n1;
for (i=0;i<10;i++)
{
n1=(struct list *)malloc(sizeof(struct list));
n1->value=i;
n1->next=head;
head=n1;
}
while( head != NULL )
{
printf("%d\n", head->value);
head = head->next;
}
}
Thank U
By
CNS