void insert()
{
counter++;
char id [12];
string title;
string author;
int year;
char num_id[12];
borrow *newptr,*p,*q;//declare
p = head;
q = NULL;
//counter++;
newptr = new borrow;//declare
cout<<"\nEnter your ID: ";
cin>>newptr->id;
cout<<"\nTitle of the book: ";
cin>>newptr->title;
getline (cin, newptr->title);
cout<<"\nAuthor: ";
cin>>newptr->author;
getline (cin, newptr->author);
cout<<"\nYear: ";
cin>>newptr->year;
newptr->next=NULL;
if(head==NULL)
{
head=newptr;
}
else
{
while(p!= NULL && strcmp(newptr->id,p->id)>0)
//while(p!= NULL && (newptr->id > p->id && newptr->id > p->id))
{
q=p;
p=p->next;
}
if (q==NULL)
{
newptr->next=head;
head=newptr;
}
else
{
newptr->next=p;
q->next=newptr;
}
}
}
void display()
{ int n=0,newptr;
pinjambuku *cur;
cur = head;
while (cur != NULL)
{
cout <<cur->id<<endl;
cout <<cur->title<<endl;
cout <<cur->author<<endl;
cout <<cur->year<<endl;
cur=cur->next;
n++;
}
cout<<" Total of ID :"<<n<<endl;
}
*** when i entered harry potter in the title, it appear potter and the same goes to the author which when i entered jack sparrow, it will print sparrow, anyone can help me?