HELLO!
There is no error and it runs, but it doesn't show my desired output. What is the problem?
#include<stdio.h>
#include<stdlib.h>
struct list
{
int data;
struct list *ptr;
};
int main()
{
struct list *clist;
struct list *top;
struct list *tmpptr;
int i;
clist=(struct list *)malloc(sizeof(struct list *));
top=clist;
for(i=1;i<=5;i++)
{
clist->data = i;
tmpptr=(struct list *)malloc(sizeof(struct list *));
clist->ptr=tmpptr;
clist=tmpptr;
}
for(clist=top;clist->ptr;clist=clist->ptr)
{
printf("%d\n", clist->data);
}
getchar();
}