The question is to search for a book title and display the details.If book title does not exist give appropriate error message.
When i tried this program it is unwantedly printing the else part. Can anyone give solution please...
Here is my code
1 2 3 4 5 6 7
case 2:{
cout<<"\n\n Enter book title\t: ";
gets(bt);
for(i=0;i<5;i++)
arr[i].srch(bt);
break;
}
1 2 3 4 5 6 7 8 9 10 11 12
void book::srch(char but[])
{
if((strcmp(but,title)==0))
{
cout<<"\n\n ----------------------------------------------\n";
cout<<" Title\t\t\tAuthor\t\tQty\tPrice\n";
cout<<" ---------------------------------------------\n\n";
cout<<title<<"\t\t"<<aname<<"\t\t"<<qty<<"\t"<<price<<"\n";
}
else cout<<"\n\n Sorry entered book does not exist!!\n\n";
}
For example if i give book name that is in the list it is printing like this
Sorry entered book does not exist!!
Sorry entered book does not exist!!
---------------------------------------------------------
Title Author Qty Price
---------------------------------------------------------
Hamlet Shakespeare 40 350
Sorry entered book does not exist!!
Sorry entered book does not exist!!