Program:
#include<stdio.h>
#include<ctype.h>
#include<string.h>
#include<stdlib.h>
//defining the properties of the fields used in the program
#define IN 1
#define OUT 0
void Addbook();
void Searchbook();
void Displaybook();
void Author();
void Titlelist();
void Stock();
void Issue();
void bookret();
void Addmembr();
void Exit();
char info[500];
struct
{
int bid;
char bname[25] ;
char author[25];
int nooftitles;
char titles[500];
int status;
}book;
struct
{
int mid;
char mname[25] ;
char department[25];
int availibcard;
int phno;
}membr;
//initializing the files used in the program
FILE *librecord;
FILE *membrrecord;
FILE *fp1;
FILE *fp2;
FILE *temp1;
FILE *temp2;
int main()
{
int choice=0,i;
printf("\n\t\t<<LIBRARY MANAGEMENT SYSTEM>>(Beta version ) \n");
do{
printf("\n\t~~MENU~~\n 1> Add A New Book\n 2> Search a book \n 3> Display Complete Information\n 4> Display All Books of An Author\n 5> List Titles of a Book\n 6> List Count of Books (Issued & On Stock)\n 7> To Issue a Book \n 8> To Rreturn a Book \n 9> Add A New Member\n 10> Exit the program\n\n\t Enter your choice <1-10>: ");
scanf("%i",&choice);
switch (choice)
{
case 1:
Addbook();
break;
case 2:
Searchbook();
break;
case 3:
Displaybook();
break;
case 4:
Author();
break;
case 5:
Titlelist();
break;
case 6:
Stock();
break;
case 7:
Issue();
break;
case 8:
bookret();
break;
case 9:
Addmembr();
break;
case 10:
Exit();
default:
printf(" ! Invalid Input...\n");
}
}while(choice!=10);
return (0);
}
void Addbook()
{
int i;book.status=IN;
//opening the librecord file
librecord = fopen("librecord.txt","a+");
printf("Enter The uniqueid of The Book :(Integer) \n");
scanf("%d",&book.bid);
printf("Enter The Name of The Book :\n");
scanf("%s",book.bname);
printf("Enter The Name of Author :\n");
scanf("%s",book.author);
printf("Enter The Number of Titles Of The Book:(Integer)\n");
scanf("%d",&book.nooftitles);
fprintf(librecord,"\n%d\t%s\t%s\t%d\t%d\t",book.bid,book.bname,book.author,book.status,book.nooftitles);
printf("Enter The Titles Of The Book : \n");
for(i=0;i<book.nooftitles;i++)
{
scanf("%s",book.titles);
fprintf(librecord,"%s\t",book.titles);
}
fclose(librecord);
printf(" (' ' ) A New Book has been Added Successfully...\n");
}
void Displaybook()
{
librecord = fopen("librecord.txt","a+");
printf("\nBookid\tName\tAuthor\tStatus\tNo.\tTitles\n",info);
do
{
fgets(info,500,librecord);
printf("%s\n",info);
}while(!feof(librecord));
fclose(librecord);
membrrecord = fopen("membrrecord.txt","a+");
printf("\nMid\tName\tDept\tPh.no\tAvailablecards\n");
do
{
fgets(info,500,membrrecord);
printf("%s\n",info);
}while(!feof(membrrecord));
fclose(membrrecord);
}
void Searchbook()
{
int i;
char Target[25],stats[3];
int Found=0;
if((librecord=fopen("librecord.txt","r"))==NULL)
printf(" ! The File is Empty...\n\n");
else
{
printf("\nEnter The Name Of Book : ");
scanf("%s",Target);
while(!feof(librecord)&& Found==0)
{
fscanf(librecord,"%d %s %s %d %d", &book.bid,book.bname,book.author,&book.status,&book.nooftitles);
if(strcmp(Target,book.bname)==0)
Found=1;
for(i=0;i<book.nooftitles;i++)
fscanf(librecord,"%s",book.titles);
}
if(Found)
{
if(book.status==IN)
strcpy(stats,"IN");
else
strcpy(stats,"OUT");
printf("\nThe Unique ID of The Book: %d\nThe Name of Book is: %s\nThe Author is: %s\nThe Book Status:%s\n\n",book.bid,book.bname,book.author,stats);
}
else if(!Found)
printf("! There is no such Entry...\n");
fclose(librecord);
}
}
void Author()
{
int i;
char Target[500];
int Found=0;
if((librecord=fopen("librecord.txt","r"))==NULL)
printf(" ! The file is empty... \n\n");
else
{
printf("\nEnter The Name Of Author : ");
scanf("%s",Target);
printf("\nBooks:");
while(!feof(librecord))
{
fscanf(librecord,"%d %s %s %d %d",&book.bid,book.bname,book.author,&book.status,&book.nooftitles);
if(strcmp(Target,book.author)==0)
{
Found=1;
printf("\n\t%s",book.bname);
}
for(i=0;i<book.nooftitles;i++)
fscanf(librecord,"%s",book.titles);
}
if(!Found)
printf(" ! There is no such Entry...\n");
fclose(librecord);
}
}
void Titlelist()
{
int i;
char Target[500];
int Found=0;
if((librecord=fopen("librecord.txt","r"))==NULL)
printf(" ! The file is empty...\n\n");
else
{
printf("\nEnter The Book Name :");
scanf("%s",Target);
while(!feof(librecord)&& Found==0)
{
fscanf(librecord,"%d %s %s %d %d",&book.bid,book.bname,book.author,&book.status,&book.nooftitles);
if(strcmp(Target,book.bname)==0)
{
Found=1;
break;
}
for(i=0;i<book.nooftitles;i++)
fscanf(librecord,"%s",book.titles);
}
if(Found)
{
//printf("The Name of book is: %s\n",book.bname);
printf("\nThe Titles:\n");
for(i=0;i<book.nooftitles;i++)
{
fscanf(librecord,"%s",book.titles);
printf("%d.%s......\n",i+1,book.titles);
}
}
else if(!Found)
printf(" ! There is no such Entry...\n");
fclose(librecord);
}
}
void Stock()
{
int i,issuecount=0,stockcount=0;
char Issued[100][20];
int Found=0;
if((librecord=fopen("librecord.txt","r"))==NULL)
printf(" ! The file is empty...\n\n");
else
{
while(!feof(librecord))
{
fscanf(librecord,"%d %s %s %d %d",&book.bid,book.bname,book.author,&book.status,&book.nooftitles);
if(book.status==IN)
{
stockcount++;
}
else
{
issuecount++;
}
for(i=0;i<book.nooftitles;i++)
fscanf(librecord,"%s",book.titles);
}
fclose(librecord);
printf("\nCount of issued Books:%d\nCount of Books in Stock:%d\n",issuecount,stockcount-1);
}
}
void Addmembr()
{
int i;
membrrecord = fopen("membrrecord.txt","a+");
printf("Enter The userid of the Member(Integer) :\n");
scanf("%d",&membr.mid);
printf("Enter The Name of the Member :\n");
scanf("%s",membr.mname);
printf("Enter The Department\n");
scanf("%s",membr.department);
printf("Enter The phone number of the member:\n");
scanf("%d",&membr.phno);
membr.availibcard=5;
fprintf(membrrecord,"\n%d\t%s\t%s\t%d\t%d\t",membr.mid,membr.mname,membr.department,membr.phno, membr.availibcard);
fclose(membrrecord);
printf("\n (' ') Added A New member Successfully...\n");
}
void Issue()
{
int mid,i,Found1=0,Found2=0;char issubookname[20];
//temp1=librecord;temp2=membrrecord;
printf("\nEnter The userid of the Member : \n");
scanf("%d",&mid);
if((membrrecord=fopen("membrrecord.txt","r"))==NULL)
printf(" ! The file is empty...\n\n");
else
{
while(!feof(membrrecord)&& Found1==0)
{
fscanf(membrrecord,"%d %s %s %d %d ",&membr.mid,membr.mname,membr.department,&membr.phno,&membr.availibcard);
if(mid==membr.mid)
{
Found1=1;
}
}
if(Found1)
{
if(membr.availibcard<1)
{
printf(" ! Library card not available...\n");
}
else
{ printf("\nEnter The Name of book :");
scanf("%s",issubookname);
if((librecord=fopen("librecord.txt","r"))==NULL)
printf(" ! The file is empty...\n\n");
else
{
while(!feof(librecord)&& Found2==0)
{
fscanf(librecord,"%d %s %s %d %d", &book.bid,book.bname,book.author,&book.status,&book.nooftitles);
if(strcmp(issubookname,book.bname)==0)
Found2=1;
for(i=0;i<book.nooftitles;i++)
fscanf(librecord,"%s",book.titles);
}
if(Found2)
{
if(book.status==0)
{
printf(" ! Book already issued...\n");
}
else
{
fp2=fopen("fp2.txt","w");
if((temp2=fopen("membrrecord.txt","r"))==NULL)
printf(" ! The file is empty...\n\n");
else
{
while(!feof(temp2))
{
fscanf(temp2,"%d %s %s %d %d ",&membr.mid,membr.mname,membr.department,&membr.phno,&membr.availibcard);
if(mid==membr.mid)
{
membr.availibcard--;
fprintf(fp2,"\n %d\t%s\t%s\t%d\t%d\t",membr.mid,membr.mname,membr.department,membr.phno, membr.availibcard);
}
else{
fprintf(fp2,"\n %d\t%s\t%s\t%d\t%d\t",membr.mid,membr.mname,membr.department,membr.phno,membr.availibcard);}
if(feof(temp2))
break;
}
}
fclose(temp2);
fclose(fp2);
fp1=fopen("fp1.txt","w");
if((temp1=fopen("librecord.txt","r"))==NULL)
printf(" ! The file is empty...\n\n");
else
{
while(!feof(temp1))
{
fscanf(temp1,"%d %s %s %d %d", &book.bid,book.bname,book.author,&book.status,&book.nooftitles);
if(feof(temp1))
break;
if(strcmp(issubookname,book.bname)!=0)
{
fprintf(fp1,"\n%d\t%s\t%s\t%d\t%d \t",book.bid,book.bname,book.author,book.status,book.nooftitles);
}
else
{
fprintf(fp1,"\n%d\t%s\t%s\t%d\t%d\t",book.bid,book.bname,book.author,0,book.nooftitles);
}
for(i=0;i<book.nooftitles;i++)
{
fscanf(temp1,"%s",book.titles);
fprintf(fp1,"%s\t",book.titles);
}
}
}
fclose(temp1);
fclose(fp1);
fclose(librecord);
fclose(membrrecord);
remove("librecord.txt");
rename("fp1.txt","librecord.txt");
remove("membrrecord.txt");
rename("fp2.txt","membrrecord.txt");
printf(" (' ') Book Successfully issued...\n");
}
}
else if(!Found2)
printf(" ! There is no such Book...\n");
}
}
}
else if(!Found1)
printf(" ! Invalid User id...\n");
}
}
void bookret()
{
int mid,i,Found1=0,Found2=0,flag=0;char retbookname[20];
temp1=librecord;temp2=membrrecord;
printf("\nEnter The userid of the Member :\n");
scanf("%d",&mid);
if((membrrecord=fopen("membrrecord.txt","r"))==NULL)
printf(" ! The file is empty...\n\n");
else
{
while(!feof(membrrecord)&& Found1==0)
{
fscanf(membrrecord,"%d %s %s %d %d ",&membr.mid,membr.mname,membr.department,&membr.phno,&membr.availibcard);
if(mid==membr.mid)
{
Found1=1;
}
}
if(Found1)
{
if(membr.availibcard>=5)
{
printf(" ! Error...\n");
}
else
{ printf("\nEnter The Name of book :");
scanf("%s",retbookname);
if((librecord=fopen("librecord.txt","r"))==NULL)
printf(" ! The file is empty\n\n");
else
{
while(!feof(librecord)&& Found2==0)
{
fscanf(librecord,"%d %s %s %d %d", &book.bid,book.bname,book.author,&book.status,&book.nooftitles);
if(strcmp(retbookname,book.bname)==0)
Found2=1;
for(i=0;i<book.nooftitles;i++)
fscanf(librecord,"%s",book.titles);
}
if(Found2)
{
if(book.status==1)
{
printf(" ! Error:Book already in stock...\n");
}
else
{
fp2=fopen("fp2.txt","w");
if((temp2=fopen("membrrecord.txt","a+"))==NULL)
printf(" ! The file is empty...\n\n");
else
{
while(!feof(temp2))
{
fscanf(temp2,"%d %s %s %d %d ",&membr.mid,membr.mname,membr.department,&membr.phno,&membr.availibcard);
if(mid==membr.mid)
{
membr.availibcard++;
fprintf(fp2,"\n %d\t%s\t%s\t%d\t%d\t",membr.mid,membr.mname,membr.department,membr.phno, membr.availibcard);
}
else
{
fprintf(fp2,"\n %d\t%s\t%s\t%d\t%d\t",membr.mid,membr.mname,membr.department,membr.phno,membr.availibcard);
}
if(feof(temp2))
break;
}
}
fclose(temp2);
fclose(fp2);
fp1=fopen("fp1.txt","w");
if((temp1=fopen("librecord.txt","r"))==NULL)
printf(" ! The file is empty...\n\n");
else
{
while(!feof(temp1))
{
fscanf(temp1,"%d %s %s %d %d", &book.bid,book.bname,book.author,&book.status,&book.nooftitles);
if(feof(temp1))
break;
if(strcmp(retbookname,book.bname)!=0)
{
fprintf(fp1,"\n%d\t%s\t%s\t%d\t%d \t",book.bid,book.bname,book.author,book.status,book.nooftitles);
}
else
{
fprintf(fp1,"\n%d\t%s\t%s\t%d\t%d\t",book.bid,book.bname,book.author,1,book.nooftitles);
}
for(i=0;i<book.nooftitles;i++)
{
fscanf(temp1,"%s",book.titles);
fprintf(fp1,"%s\t",book.titles);
}
}
}
fclose(temp1);
fclose(fp1);
fclose(librecord);
fclose(membrrecord);
printf("('') Book Successfully Returned...\n");
remove("librecord.txt");
rename("fp1.txt","librecord.txt");
remove("membrrecord.txt");
rename("fp2.txt","membrrecord.txt");
}
}
else if(!Found2)
printf("! There is no such Book...\n");
}
}
}
else if(!Found1)
printf("! Invalid User id...\n");
}
}
void Exit()
{
exit(0);
}
Output:
nn@linuxmint ~ $ gcc ll.c
nn@linuxmint ~ $ ./a.out
<<LIBRARY MANAGEMENT SYSTEM>>(Beta version )
~~MENU~~
1> Add A New Book
2> Search a book
3> Display Complete Information
4> Display All Books of An Author
5> List Titles of a Book
6> List Count of Books (Issued & On Stock)
7> To Issue a Book
8> To Rreturn a Book
9> Add A New Member
10> Exit the program
Enter your choice <1-10>: 1
Enter The uniqueid of The Book :(Integer)
100
Enter The Name of The Book :
n1
Enter The Name of Author :
a1
Enter The Number of Titles Of The Book:(Integer)
2
Enter The Titles Of The Book :
t1
t2
(' ' ) A New Book has been Added Successfully...
please send me report on library management u had....ma email:har.11.dx@gmail.com
ReplyDeletePLEASE SEND ME D REPORT OF LIBRARY MANAGEMENT U HAD... MY MAIL ID - adarshadash@yahoo.in
ReplyDeleteplease send me report @ preetish1993@gmail.com
ReplyDeleteplease send me the library report at skwong08@hotmail.com
ReplyDeleteplease send the report to my mail id rajjesume@gmail.com
ReplyDeleteplease send me the library report id parames5201@gmail.com
ReplyDeletepls send me the library report id isratfardous@gmail.com
ReplyDeleteplz send me the report for this project as it is perceptive and outstanding project n I liked it.
ReplyDeleteId: vineetloveronaldo@gmail.com
How do I use set intersection concept of relational algebra in this program?
ReplyDeletePlease help me with my project. email id: tanu.sjce@gmail.com
How to write a c code for intersection between two libraries with union compatibility?
ReplyDeletePlease try to send the code. My email id: tanu.sjce@gmail.com
Please send me the report for this project. My email id is nishithar55@gmail.com
ReplyDeletePlease send me the report for this project. My email id is nishithar55@gmail.com
ReplyDeletepls send me report on mst.momin@gmail.com
ReplyDeletePiease send me a report on abhishekrajawat1098@gmail.com
ReplyDeletePiease send me a report on lanthi.gou@gmail.com
ReplyDeleteTo know the programming technique: "Make Your Program Trial Version in C" visit:
ReplyDeleteudebayan.blogspot.com
BSP files contain layout, object, and resource information for specific level maps.
ReplyDeleteBSP File Management System
This comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteGreat programming for Library Management System. Helps for people looking for code.
ReplyDeleteGreat Help , to know importance of library management system
ReplyDeletepls go through our blog.
Really amazing blog, I’d love to discover some extra information.
ReplyDeletecan u give me the algorithm for thus lz send me to shivamanand312@gmail.com
ReplyDeleteSend me all it's output
ReplyDeletePlease send me the report of this program to this email simon.atem14@gmail.com
ReplyDeletehello, please send me the report of this program: bacalebibang@gmail.com
ReplyDeleteThis comment has been removed by the author.
ReplyDeletePlz send me the report id of this program. anirbanmaiti37@gmail.com
ReplyDeletecan you please send the report to my id: shahtirth206@gmail.com
ReplyDeletesend me ur report thanks
ReplyDeletesend please
ReplyDeletesend report at sharadmathur4@gmail.com
ReplyDeleteplease i need it fast
ReplyDeleteThanks for sharing the code of Library Management System. Very helpful for beginners.
ReplyDeleteThanks.It is very useful for beginners.
ReplyDeleteIt is very easy to understand..
I am DR. GURUJI NAVGRAHA from India a spell caster that has been successfully providing results to my clients for over many years. I use nothing but 100% safe and ancient Indian spiritual methods,I will reunite your ex partner back to you, stop an impending divorce or break-up, and bring back the passion, love, lust, communication and commitment between broken lovers. Don't live in a life unfilled without the one you truly desire. Let me show you the real results you've been searching for,My Powerful Indian
ReplyDeleteSpiritual Spell are :
wedding ritual, healing ritual,Divorce stop ritual,separation ritual,love ritual,protection ritual,self-confidence ritual,child ritual,success ritual,Return Lover ritual,restore passion ritual Save Marriage Spells,Prevent Divorce Spells,Cheating ritual Remove Ex ritual,Business increase,Money
ritual,Famous ritual,Indian Spiritual Healing center is the answer
Email: casterspell481@gmail.com
Whatsap: +919108256518
DR. GURUJI NAVGRAHA
Pls send report my mail prudhvialluarjun1122@gmail.com
ReplyDeletesend me the report please !! oulimeyouness@gmail.com
ReplyDeletewow this post is amazing .. thanks for sharing please see my post also here is my post for
ReplyDeleteTop 10 best books to learn C Programming
Hi goodmorning.. can i ask a favor, i was struggling with the project i have right now.. can you send me a simple c program in library management please.. i hope you can read this .. it will be a big help. Thank you god speed
ReplyDeleteThanks for sharing such a wonderful blog. Library Management Software
ReplyDeleteThanks for sharing this wonderful information. Your information is very helpful for me.
ReplyDeleteSatta matka online
Play matka online
Rajdhani Night Satta Matka
Laxmi matka
Play matka online
Nice blog! Thank you for sharing the best information about school management software.
ReplyDeleteVery valuable and nice blog, thankyou for sharing with us. If someone know about Koha installation by eLibSol, then please contact us. We solve your query quickly.
ReplyDelete