Hi,all.I want to know why this program can not run faultlessly?
Thanks to all.
#include <stdio.h>
#include <stdlib.h>
typedef struct link{
char data;
struct link * next;
struct link * pre;
}list;
main()
{
list * head=NULL; /* Define the head node */
list * linklist; /* Define the link list */
list * p1,* p2; /* Define tempopary node */
char flag; /* Define the sign*/
int count; /* Define the member count*/
printf("Input count of data-member\n");
printf("count:");
scanf("%d",&count);
linklist=(list *)malloc(sizeof(list));
head->pre=NULL;
head->next=linklist;
p1=NULL;
printf("Input member's data\n");
for(int i=0;i<count;i++)
{
printf("Member%d :",i+1);
scanf("%d",linklist->data);
p1=(list *)malloc(sizeof(list));
linklist->next=p1;
p1->pre=linklist;
linklist=p1;
}
linklist->next=NULL;
p2=head->next;
i=0;
while(p2!=NULL)
{
printf("Node[%d] :",i++);
printf("%c",p2->data);
p2=p2->next;
}
}