هذا البرنامج يقراء ويخزن في الlinked list القراءه صحيحه بس المشكله انه ما يطبع ارجو منكم تصححيح الخطأ وشكرا
#include
#include
#include
typedef struct node{
char bookn[20];
char bookw[20];
int snumber;
struct node *link;
}node;
typedef struct list{
node *head;
}list;
void create(list*);
void add_node(list*,node*,node*);
void add_data(list*);
void print_list(list);
void main()
{
list l;
create(&l);
add_data(&l);
print_list(l);
}
/***********************/
void create(list*l){
l->head=NULL;
}
/********/
void add_node(list*l,node*pred,node*pnew)
{
if(pred==NULL){
pnew->link=l->head;
l->head=pnew;
}
else{
pnew->link=pred->link;
pred->link=pnew;
}
}
/**************************/
void add_data(list*l){
node *pnew,*pred=NULL,*ploc;
pnew=(node*)malloc( sizeof(node) );
printf("Enter the name of the book:");
scanf("%s",pnew->bookn);
while( strcmp(pnew->bookn ,"$")){
printf("Enter the name of the man who write the book:");
scanf("%s",pnew->bookw);
printf("Enter the serual number of the book:");
scanf("%d",&pnew->snumber);
add_node(l,pred,pnew);
printf("nEnter the name of the book:");
scanf("%s",pnew->bookn);
}
}
/************************/
void print_list(list l)
{
node *p;
p=l.head;
while(p!=NULL){
printf("book name is %sn",(p->bookn));
printf("other name is %sn",(p->bookw));
printf("serial number is %dn",(p->snumber));
printf("*************************************");
p=p->link;
}
}
/************************/