
Hello I am developing program of library management system where I need to use C++ but without class. So I am facing problem at two place, One is when there are no books information at that time it should show No books found and the other is while searching the books through ISBN number. Both the things are not happening. So please anyone try to solve it...
#include<stdio.h>
#include<conio.h>
#include<iostream.h>
struct library
{
char isbn[10],b_name[15],a_name[15],search[10];
}stud[100];
void main()
{
int i,j,a,flag=0;
char op,b;
do
{
clrscr();
cout<<"Press 1 to input information"<<endl;
cout<<"Press 2 to display book information"<<endl;
cout<<"Press 3 to search for book"<<endl;
cout<<"Press 4 to exit"<<endl;
cin>>a;
switch(a)
{
case 1:
{
clrscr();
cout<<"How many records do you want to enter: \t";
cin>>j;
clrscr();
for(i=0;i<j;i++)
{
cout<<"Enter Record: "<<i+1<<endl;
cout<<"Enter ISBN Number: \t";
cin>>stud[i].isbn;
cout<<"Enter Book Name: \t";
cin>>stud[i].b_name;
cout<<"Enter Author Name: \t";
cin>>stud[i].a_name;
}
break;
}
case 2:
{
clrscr();
cout<<"----------------------------------------------------------------------------"<<endl;
cout<<"ISBN Number\t\t\tBook Name\t\t\tAuthor Name"<<endl;
cout<<"----------------------------------------------------------------------------"<<endl;
> if(stud[0].isbn==" ")
> {
> cout<<"No Recods found";
> }
else
{
for(i=0;i<j;i++)
{
cout<<stud[i].isbn<<"\t\t\t\t"<<stud[i].b_name<<"\t\t\t\t"<<stud[i].a_name<<endl;
}
}
break;
}
case 3:
{
cout<<"Enter ISBN number that you want to search";
cin>>stud[0].search;
cout<<"----------------------------------------------------------------------------"<<endl;
cout<<"ISBN Number\t\t\tBook Name\t\t\tAuthor Name"<<endl;
cout<<"----------------------------------------------------------------------------"<<endl;
for(i=0;i<j;i++)
{
> if(stud[i].isbn==stud[0].search)
> {
> cout<<stud[i].isbn<<"\t\t\t"<<stud[i].b_name<<"\t\t\t"<<stud[i].a_name<<endl;
> flag = 1;
}
}
if(flag==0)
cout<<"Sorry No Reords found"<<endl;
// cout<<"Real"<<stud[i].isbn<<"Search"<<stud[0].isbn;
break;
}
case 4:
{
}
}
cout<<"Do you want to continue: ";
cin>>op;
}while(op=='Y'||op=='y');
getch();
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.