#include<stdio.h>
#include<conio.h>
#include<string.h>
struct book{
char title[30];
int book_isbn[13];
};book library
int x, found,count,y;
char title[20][30];
void setup()
{
strcpy(title[0], "Wind In The Willows");
strcpy(title[1], "Fright Night");
strcpy(title[2], "Women From Venus, Men are from Mars");
strcpy(title[3], "Happy Days");
strcpy(title[4], "Gone Fishing");
strcpy(title[5], "My Sql");
strcpy(title[6], "About Nothing");
strcpy(title[7], "Beowulf");
strcpy(title[8], "Shopoholic");
strcpy(title[9], "Programming for Leraners");
strcpy(title[10], "I love You");
strcpy(title[11], "cardinal");
strcpy(title[12], "The Birds");
strcpy(title[13], "Three Men and Mice");
strcpy(title[14], "Stig Of The Dump");
strcpy(title[15], "Nowhere");
strcpy(title[16], "Zulu");
strcpy(title[17], "Deal with It");
strcpy(title[18], "Klaxons");
strcpy(title[19], "Learn to speak Spanish");
isbn[0]=1234777372037;
isbn[1]=2345109283274;
isbn[3]=3456280364781;
isbn[4]=4567982745729;
isbn[5]=5678111882763;
isbn[6]=6789120356788;
isbn[7]=7890999243552;
isbn[8]=8901188826666;
isbn[9]=9012224563728;
isbn[10]=012312222112;
isbn[11]=112344882773;
isbn[12]=122309412036;
isbn[13]=132300098765;
isbn[14]=142333387887;
isbn[15]=152322229999;
isbn[16]=162322222000;
isbn[17]=172311993873;
isbn[18]=182333333221;
isbn[19]=192300000000;
count=20;
}
void title()
{
for(x=0;x<20;x++)
{
printf("\n Enter a Title ");
gets(sname);
printf("\n Please Enter Title:");
gets(title);
found=0;
for(x=0;x<20;x++)
if(strcmpi(title[x])==0)
{
printf("\n%s",title[x]);
found=1;
}
if(found==0)
printf("\n Book not found on Database ");
getch();
}
void searched()
{
}
void sort()
{
int swap;
do
{
swap=0;
for (x=0;x<count-1;x++)
{
if(strcmpi(book[x].title,book[x+1].title)>0)
{
temp=book[x];
book[x]=book[x+1];
book[x+1]=temp;
swap=1;
}}
}while(swap!=0);
for(x=0;x<count;x++)
{
printf("\n%s %d",book[x].title,book[x].isbn);
}
getch();
}
void change()
{
}
void delstud()
{
printf("\n Please Enter A Title:");
gets(title);
found=0;
for(x=0;x<count;x++)
if(strcmpi(title,book[x].title)==0)
{
printf("\n%s %d",book[x].title,book[x].isbn);
found=1;
for(y=x;y<count;y++)
{
book[y]=book[y+1];
}
count=count-1;
}
if(found==0)
printf("\n Book not found on Database ");
getch();
}
void addbook()
{
if(count<30)
{
printf("\n Enter a Name of a book");
gets(book[count].title);
printf("\nEnter new Book ISBN");
scanf("%d",&book[count].isbn);
count++;
}
else
{
printf("\nDatabase Full");
getche();
}
}
void writefile()
{
FILE*f;
f=fopen("book.dat","wb");
for(x=0;x<count; x++)
fwrite(&book[x],sizeof(struct books),1,f);
fclose(f);
}
void readfile()
{
FILE*f;
count=1;
if((f=fopen("book.dat","rb"))==NULL)
{
printf("\n book.dat file not found");
getch();
count=0;
}
else
{
do
{
count=count+1;
fread(&book[count],sizeof(struct books),1,f);
}while(!feof(f));
fclose(f);
}
}
void menu()
{
int choice;
do
{
clrscr();
printf("\n\t\tl. \tSearch for Title");
printf("\n\t\t2. \tSearch by ISBN");
printf("\n\t\t3. \tSort
printf("\n\t\t4. \tChange ISBN");
printf("\n\t\t5. \tDelete BOOK");
printf("\n\t\t6. \tAdd Book");
printf("\n\t\t7. \tExit");
printf("\n\t\t. \tEnter a Menu Choice->");
scanf("%d", &choice);
fflush(stdin);
switch(choice)
{
case 1:searchtitle();
break;
case 2:searched();
break;
case 3:sort();
break;
case 4:change();
break;
case 5:delbook();
break;
case 6:addbook();
break;
default: printf("\nInvalid Choice Entered");
getch();
}
} while (choice!=8);
}
void main()
{
setup();
menu();
}
dO i DO THIS AS A LIBRARY??
THANKS FOR ANY HELP