Library Management System In C With Source Code
The Library Management System In C is develop in C programming language and creating in a console based, This Simple Library Management System Project In C you can perform functions such as add books, return books, issue books, delete record of books issued, view record of books issued, search for books, and more. File handling has been extensively used in this project for almost all functions. So, this project can definitely guide you to understand C mini projects in a better way.
A Library Management System C Program has six departments – Computer, Electrical, Civil, Electronics, Mechanical and Architecture. These departments work simultaneously with the operations mentioned above. You can add a book to the Civil section, delete a book from the Electrical section or view issued book details of the Mechanical department.
This system also includes a downloadable Library Management System C Project Source Code for free, just find the downloadable source code below and click to start downloading.
Watch the video here to see the full running Library management system in C source code.
To start creating a Library Management System In C, make sure that you have code blocks or any platform of c language installed in your computer.
Steps on how to create a Library Management System In C
Library Management System In C With Source Code
- Step 1: Create a new project.
First open the code blocks IDE and click “create a new project“.
- Step 2: Choose console application.
Second click the “console application” and after that click “next“.
- Step 3: Choose C language.
Third choose “C language” and click “next“.
- Step 4: Name Your Project.
Fourth name the project you’ve created and click “next” after that click “finish“.
- Step 5: The actual code.
You are free to copy the given source code below or download the downloadable source code given.
The Code Given Below Is For The Main Module
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 |
void mainmenu() { //loaderanim(); system("cls"); // textbackground(13); int i; gotoxy(20,3); printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2 MAIN MENU \xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2"); // show_mouse(); gotoxy(20,5); printf("\xDB\xDB\xDB\xDB\xB2 1. Add Books "); gotoxy(20,7); printf("\xDB\xDB\xDB\xDB\xB2 2. Delete books"); gotoxy(20,9); printf("\xDB\xDB\xDB\xDB\xB2 3. Search Books"); gotoxy(20,11); printf("\xDB\xDB\xDB\xDB\xB2 4. Issue Books"); gotoxy(20,13); printf("\xDB\xDB\xDB\xDB\xB2 5. View Book list"); gotoxy(20,15); printf("\xDB\xDB\xDB\xDB\xB2 6. Edit Book's Record"); gotoxy(20,17); printf("\xDB\xDB\xDB\xDB\xB2 7. Close Application"); gotoxy(20,19); printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2"); gotoxy(20,20); t(); gotoxy(20,21); printf("Enter your choice:"); switch(getch()) { case '1': addbooks(); break; case '2': deletebooks(); break; case '3': searchbooks(); break; case '4': issuebooks(); break; case '5': viewbooks(); break; case '6': editbooks(); break; case '7': { system("cls"); gotoxy(16,3); printf("\tLibrary Management System"); gotoxy(16,4); printf("\tMini Project in C"); gotoxy(16,5); printf("******************************************"); gotoxy(16,10); printf("*******************************************"); gotoxy(16,11); printf("*******************************************"); gotoxy(16,13); printf("********************************************"); gotoxy(10,17); printf("Exiting in 3 second...........>"); //flushall(); Sleep(3000); exit(0); } default: { gotoxy(10,23); printf("\aWrong Entry!!Please re-entered correct option"); if(getch()) mainmenu(); } } } |
In this module which is the main module of the system.
The Code Given Below Is For The Add Books Module
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 |
void addbooks(void) //funtion that add books { system("cls"); int i; gotoxy(20,5); printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2SELECT CATEGOIES\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2"); gotoxy(20,7); printf("\xDB\xDB\xDB\xDB\xB2 1. Computer"); gotoxy(20,9); printf("\xDB\xDB\xDB\xDB\xB2 2. Electronics"); gotoxy(20,11); printf("\xDB\xDB\xDB\xDB\xB2 3. Electrical"); gotoxy(20,13); printf("\xDB\xDB\xDB\xDB\xB2 4. Civil"); gotoxy(20,15); printf("\xDB\xDB\xDB\xDB\xB2 5. Mechanical"); gotoxy(20,17); printf("\xDB\xDB\xDB\xDB\xB2 6. Architecture"); gotoxy(20,19); printf("\xDB\xDB\xDB\xDB\xB2 7. Back to main menu"); gotoxy(20,21); printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2"); gotoxy(20,22); printf("Enter your choice:"); scanf("%d",&s); if(s==7) mainmenu() ; system("cls"); fp=fopen("Bibek.dat","ab+"); if(getdata()==1) { a.cat=catagories[s-1]; fseek(fp,0,SEEK_END); fwrite(&a,sizeof(a),1,fp); fclose(fp); gotoxy(21,14); printf("The record is sucessfully saved"); gotoxy(21,15); printf("Save any more?(Y / N):"); if(getch()=='n') mainmenu(); else system("cls"); addbooks(); } } |
In this module which is the module for the adding of books.
The Code Given Below Is For The Delete Module
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 |
void deletebooks() //function that delete items from file fp { system("cls"); int d; char another='y'; while(another=='y') //infinite loop { system("cls"); gotoxy(10,5); printf("Enter the Book ID to delete:"); scanf("%d",&d); fp=fopen("Bibek.dat","rb+"); rewind(fp); while(fread(&a,sizeof(a),1,fp)==1) { if(a.id==d) { gotoxy(10,7); printf("The book record is available"); gotoxy(10,8); printf("Book name is %s",a.name); gotoxy(10,9); printf("Rack No. is %d",a.rackno); findbook='t'; } } if(findbook!='t') { gotoxy(10,10); printf("No record is found modify the search"); if(getch()) mainmenu(); } if(findbook=='t' ) { gotoxy(10,9); printf("Do you want to delete it?(Y/N):"); if(getch()=='y') { ft=fopen("test.dat","wb+"); //temporary file for delete rewind(fp); while(fread(&a,sizeof(a),1,fp)==1) { if(a.id!=d) { fseek(ft,0,SEEK_CUR); fwrite(&a,sizeof(a),1,ft); //write all in tempory file except that } //we want to delete } fclose(ft); fclose(fp); remove("Bibek.dat"); rename("test.dat","Bibek.dat"); //copy all item from temporary file to fp except that fp=fopen("Bibek.dat","rb+"); //we want to delete if(findbook=='t') { gotoxy(10,10); printf("The record is sucessfully deleted"); gotoxy(10,11); printf("Delete another record?(Y/N)"); } } else mainmenu(); fflush(stdin); another=getch(); } } gotoxy(10,15); mainmenu(); } |
In this module which is the module for deleting the data.
The Code Given Below Is For The Search Module
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 |
void searchbooks() { system("cls"); int d; printf("*****************************Search Books*********************************"); gotoxy(20,10); printf("\xDB\xDB\xDB\xB2 1. Search By ID"); gotoxy(20,14); printf("\xDB\xDB\xDB\xB2 2. Search By Name"); gotoxy( 15,20); printf("Enter Your Choice"); fp=fopen("Bibek.dat","rb+"); //open file for reading propose rewind(fp); //move pointer at the begining of file switch(getch()) { case '1': { system("cls"); gotoxy(25,4); printf("****Search Books By Id****"); gotoxy(20,5); printf("Enter the book id:"); scanf("%d",&d); gotoxy(20,7); printf("Searching........"); while(fread(&a,sizeof(a),1,fp)==1) { if(a.id==d) { Sleep(2); gotoxy(20,7); printf("The Book is available"); gotoxy(20,8); printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2"); gotoxy(20,9); printf("\xB2 ID:%d",a.id);gotoxy(47,9);printf("\xB2"); gotoxy(20,10); printf("\xB2 Name:%s",a.name);gotoxy(47,10);printf("\xB2"); gotoxy(20,11); printf("\xB2 Author:%s ",a.Author);gotoxy(47,11);printf("\xB2"); gotoxy(20,12); printf("\xB2 Qantity:%d ",a.quantity);gotoxy(47,12);printf("\xB2"); gotoxy(47,11);printf("\xB2"); gotoxy(20,13); printf("\xB2 Price:Rs.%.2f",a.Price);gotoxy(47,13);printf("\xB2"); gotoxy(20,14); printf("\xB2 Rack No:%d ",a.rackno);gotoxy(47,14);printf("\xB2"); gotoxy(20,15); printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2"); findbook='t'; } } if(findbook!='t') //checks whether conditiion enters inside loop or not { gotoxy(20,8); printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2"); gotoxy(20,9);printf("\xB2"); gotoxy(38,9);printf("\xB2"); gotoxy(20,10); printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2"); gotoxy(22,9);printf("\aNo Record Found"); } gotoxy(20,17); printf("Try another search?(Y/N)"); if(getch()=='y') searchbooks(); else mainmenu(); break; } case '2': { char s[15]; system("cls"); gotoxy(25,4); printf("****Search Books By Name****"); gotoxy(20,5); printf("Enter Book Name:"); scanf("%s",s); int d=0; while(fread(&a,sizeof(a),1,fp)==1) { if(strcmp(a.name,(s))==0) //checks whether a.name is equal to s or not { gotoxy(20,7); printf("The Book is available"); gotoxy(20,8); printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2"); gotoxy(20,9); printf("\xB2 ID:%d",a.id);gotoxy(47,9);printf("\xB2"); gotoxy(20,10); printf("\xB2 Name:%s",a.name);gotoxy(47,10);printf("\xB2"); gotoxy(20,11); printf("\xB2 Author:%s",a.Author);gotoxy(47,11);printf("\xB2"); gotoxy(20,12); printf("\xB2 Qantity:%d",a.quantity);gotoxy(47,12);printf("\xB2"); gotoxy(20,13); printf("\xB2 Price:Rs.%.2f",a.Price);gotoxy(47,13);printf("\xB2"); gotoxy(20,14); printf("\xB2 Rack No:%d ",a.rackno);gotoxy(47,14);printf("\xB2"); gotoxy(20,15); printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2"); d++; } } if(d==0) { gotoxy(20,8); printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2"); gotoxy(20,9);printf("\xB2"); gotoxy(38,9);printf("\xB2"); gotoxy(20,10); printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2"); gotoxy(22,9);printf("\aNo Record Found"); } gotoxy(20,17); printf("Try another search?(Y/N)"); if(getch()=='y') searchbooks(); else mainmenu(); break; } default : getch(); searchbooks(); } fclose(fp); } |
In this module which is the module for searching books.
The Code Given Below Is For The Issuing Module
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 |
void issuebooks(void) //function that issue books from library { int t; system("cls"); printf("********************************ISSUE SECTION**************************"); gotoxy(10,5); printf("\xDB\xDB\xDB\xDb\xB2 1. Issue a Book"); gotoxy(10,7); printf("\xDB\xDB\xDB\xDb\xB2 2. View Issued Book"); gotoxy(10,9); printf("\xDB\xDB\xDB\xDb\xB2 3. Search Issued Book"); gotoxy(10,11); printf("\xDB\xDB\xDB\xDb\xB2 4. Remove Issued Book"); gotoxy(10,14); printf("Enter a Choice:"); switch(getch()) { case '1': //issue book { system("cls"); int c=0; char another='y'; while(another=='y') { system("cls"); gotoxy(15,4); printf("***Issue Book section***"); gotoxy(10,6); printf("Enter the Book Id:"); scanf("%d",&t); fp=fopen("Bibek.dat","rb"); fs=fopen("Issue.dat","ab+"); if(checkid(t)==0) //issues those which are present in library { gotoxy(10,8); printf("The book record is available"); gotoxy(10,9); printf("There are %d unissued books in library ",a.quantity); gotoxy(10,10); printf("The name of book is %s",a.name); gotoxy(10,11); printf("Enter student name:"); scanf("%s",a.stname); //struct dosdate_t d; //for current date //_dos_getdate(&d); //a.issued.dd=d.day; //a.issued.mm=d.month; //a.issued.yy=d.year; gotoxy(10,12); printf("Issued date=%d-%d-%d",a.issued.dd,a.issued.mm,a.issued.yy); gotoxy(10,13); printf("The BOOK of ID %d is issued",a.id); a.duedate.dd=a.issued.dd+RETURNTIME; //for return date a.duedate.mm=a.issued.mm; a.duedate.yy=a.issued.yy; if(a.duedate.dd>30) { a.duedate.mm+=a.duedate.dd/30; a.duedate.dd-=30; } if(a.duedate.mm>12) { a.duedate.yy+=a.duedate.mm/12; a.duedate.mm-=12; } gotoxy(10,14); printf("To be return:%d-%d-%d",a.duedate.dd,a.duedate.mm,a.duedate.yy); fseek(fs,sizeof(a),SEEK_END); fwrite(&a,sizeof(a),1,fs); fclose(fs); c=1; } if(c==0) { gotoxy(10,11); printf("No record found"); } gotoxy(10,15); printf("Issue any more(Y/N):"); fflush(stdin); another=getche(); fclose(fp); } break; } case '2': //show issued book list { system("cls"); int j=4; printf("*******************************Issued book list*******************************\n"); gotoxy(2,2); printf("STUDENT NAME CATEGORY ID BOOK NAME ISSUED DATE RETURN DATE"); fs=fopen("Issue.dat","rb"); while(fread(&a,sizeof(a),1,fs)==1) { gotoxy(2,j); printf("%s",a.stname); gotoxy(18,j); printf("%s",a.cat); gotoxy(30,j); printf("%d",a.id); gotoxy(36,j); printf("%s",a.name); gotoxy(51,j); printf("%d-%d-%d",a.issued.dd,a.issued.mm,a.issued.yy ); gotoxy(65,j); printf("%d-%d-%d",a.duedate.dd,a.duedate.mm,a.duedate.yy); //struct dosdate_t d; //_dos_getdate(&d); gotoxy(50,25); // printf("Current date=%d-%d-%d",d.day,d.month,d.year); j++; } fclose(fs); gotoxy(1,25); returnfunc(); } break; case '3': //search issued books by id { system("cls"); gotoxy(10,6); printf("Enter Book ID:"); int p,c=0; char another='y'; while(another=='y') { scanf("%d",&p); fs=fopen("Issue.dat","rb"); while(fread(&a,sizeof(a),1,fs)==1) { if(a.id==p) { issuerecord(); gotoxy(10,12); printf("Press any key......."); getch(); issuerecord(); c=1; } } fflush(stdin); fclose(fs); if(c==0) { gotoxy(10,8); printf("No Record Found"); } gotoxy(10,13); printf("Try Another Search?(Y/N)"); another=getch(); } } break; case '4': //remove issued books from list { system("cls"); int b; FILE *fg; //declaration of temporary file for delete char another='y'; while(another=='y') { gotoxy(10,5); printf("Enter book id to remove:"); scanf("%d",&b); fs=fopen("Issue.dat","rb+"); while(fread(&a,sizeof(a),1,fs)==1) { if(a.id==b) { issuerecord(); findbook='t'; } if(findbook=='t') { gotoxy(10,12); printf("Do You Want to Remove it?(Y/N)"); if(getch()=='y') { fg=fopen("record.dat","wb+"); rewind(fs); while(fread(&a,sizeof(a),1,fs)==1) { if(a.id!=b) { fseek(fs,0,SEEK_CUR); fwrite(&a,sizeof(a),1,fg); } } fclose(fs); fclose(fg); remove("Issue.dat"); rename("record.dat","Issue.dat"); gotoxy(10,14); printf("The issued book is removed from list"); } } if(findbook!='t') { gotoxy(10,15); printf("No Record Found"); } } gotoxy(10,16); printf("Delete any more?(Y/N)"); another=getch(); } } default: gotoxy(10,18); printf("\aWrong Entry!!"); getch(); issuebooks(); break; } gotoxy(1,30); returnfunc(); } |
In this module which is the module for issuing books.
The Code Given Below Is For The Viewing Module
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
void viewbooks(void) //show the list of book persists in library { int i=0,j; system("cls"); gotoxy(1,1); printf("*********************************Book List*****************************"); gotoxy(2,2); printf(" CATEGORY ID BOOK NAME AUTHOR QTY PRICE RackNo "); j=4; fp=fopen("Bibek.dat","rb"); while(fread(&a,sizeof(a),1,fp)==1) { gotoxy(3,j); printf("%s",a.cat); gotoxy(16,j); printf("%d",a.id); gotoxy(22,j); printf("%s",a.name); gotoxy(36,j); printf("%s",a.Author); gotoxy(50,j); printf("%d",a.quantity); gotoxy(57,j); printf("%.2f",a.Price); gotoxy(69,j); printf("%d",a.rackno); printf("\n\n"); j++; i=i+a.quantity; } gotoxy(3,25); printf("Total Books =%d",i); fclose(fp); gotoxy(35,25); returnfunc(); } |
In this module which is the module for viewing data.
The Code Given Below Is For The Editing Module
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
void editbooks(void) //edit information about book { system("cls"); int c=0; int d,e; gotoxy(20,4); printf("****Edit Books Section****"); char another='y'; while(another=='y') { system("cls"); gotoxy(15,6); printf("Enter Book Id to be edited:"); scanf("%d",&d); fp=fopen("Bibek.dat","rb+"); while(fread(&a,sizeof(a),1,fp)==1) { if(checkid(d)==0) { gotoxy(15,7); printf("The book is availble"); gotoxy(15,8); printf("The Book ID:%d",a.id); gotoxy(15,9); printf("Enter new name:");scanf("%s",a.name); gotoxy(15,10); printf("Enter new Author:");scanf("%s",a.Author); gotoxy(15,11); printf("Enter new quantity:");scanf("%d",&a.quantity); gotoxy(15,12); printf("Enter new price:");scanf("%f",&a.Price); gotoxy(15,13); printf("Enter new rackno:");scanf("%d",&a.rackno); gotoxy(15,14); printf("The record is modified"); fseek(fp,ftell(fp)-sizeof(a),0); fwrite(&a,sizeof(a),1,fp); fclose(fp); c=1; } if(c==0) { gotoxy(15,9); printf("No record found"); } } gotoxy(15,16); printf("Modify another Record?(Y/N)"); fflush(stdin); another=getch() ; } returnfunc(); } |
In this module which is the module for editing data.
The Code Given Below Is For The Return Function Module
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 |
void returnfunc(void) { { printf(" Press ENTER to return to main menu"); } a: if(getch()==13) //allow only use of enter mainmenu(); else goto a; } int getdata() { int t; gotoxy(20,3);printf("Enter the Information Below"); gotoxy(20,4);printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2"); gotoxy(20,5); printf("\xB2");gotoxy(46,5);printf("\xB2"); gotoxy(20,6); printf("\xB2");gotoxy(46,6);printf("\xB2"); gotoxy(20,7); printf("\xB2");gotoxy(46,7);printf("\xB2"); gotoxy(20,8); printf("\xB2");gotoxy(46,8);printf("\xB2"); gotoxy(20,9); printf("\xB2");gotoxy(46,9);printf("\xB2"); gotoxy(20,10); printf("\xB2");gotoxy(46,10);printf("\xB2"); gotoxy(20,11); printf("\xB2");gotoxy(46,11);printf("\xB2"); gotoxy(20,12); printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2"); gotoxy(21,5); printf("Category:"); gotoxy(31,5); printf("%s",catagories[s-1]); gotoxy(21,6); printf("Book ID:\t"); gotoxy(30,6); scanf("%d",&t); if(checkid(t) == 0) { gotoxy(21,13); printf("\aThe book id already exists\a"); getch(); mainmenu(); return 0; } a.id=t; gotoxy(21,7); printf("Book Name:");gotoxy(33,7); scanf("%s",a.name); gotoxy(21,8); printf("Author:");gotoxy(30,8); scanf("%s",a.Author); gotoxy(21,9); printf("Quantity:");gotoxy(31,9); scanf("%d",&a.quantity); gotoxy(21,10); printf("Price:");gotoxy(28,10); scanf("%f",&a.Price); gotoxy(21,11); printf("Rack No:");gotoxy(30,11); scanf("%d",&a.rackno); return 1; } int checkid(int t) //check whether the book is exist in library or not { rewind(fp); while(fread(&a,sizeof(a),1,fp)==1) if(a.id==t) return 0; //returns 0 if book exits return 1; //return 1 if it not } |
In this module which is the module for return function.
Complete Source Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 |
#include<windows.h> #include<stdio.h> #include<conio.h> #include <stdlib.h> #include<string.h> //contains strcmp(),strcpy(),strlen(),etc #include<ctype.h> //contains toupper(), tolower(),etc #include<dos.h> //contains _dos_getdate #include<time.h> //#include<bios.h> #define RETURNTIME 15 char catagories[][15]={"Computer","Electronics","Electrical","Civil","Mechnnical","Architecture"}; void returnfunc(void); void mainmenu(void); void addbooks(void); void deletebooks(void); void editbooks(void); void searchbooks(void); void issuebooks(void); void viewbooks(void); void closeapplication(void); int getdata(); int checkid(int); int t(void); //void show_mouse(void); void Password(); void issuerecord(); void loaderanim(); //list of global files that can be acceed form anywhere in program FILE *fp,*ft,*fs; COORD coord = {0, 0}; //list of global variable int s; char findbook; char password[10]={"codewithc"}; void gotoxy (int x, int y) { coord.X = x; coord.Y = y; // X and Y coordinates SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), coord); } struct meroDate { int mm,dd,yy; }; struct books { int id; char stname[20]; char name[20]; char Author[20]; int quantity; float Price; int count; int rackno; char *cat; struct meroDate issued; struct meroDate duedate; }; struct books a; int main() { Password(); getch(); return 0; } void mainmenu() { //loaderanim(); system("cls"); // textbackground(13); int i; gotoxy(20,3); printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2 MAIN MENU \xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2"); // show_mouse(); gotoxy(20,5); printf("\xDB\xDB\xDB\xDB\xB2 1. Add Books "); gotoxy(20,7); printf("\xDB\xDB\xDB\xDB\xB2 2. Delete books"); gotoxy(20,9); printf("\xDB\xDB\xDB\xDB\xB2 3. Search Books"); gotoxy(20,11); printf("\xDB\xDB\xDB\xDB\xB2 4. Issue Books"); gotoxy(20,13); printf("\xDB\xDB\xDB\xDB\xB2 5. View Book list"); gotoxy(20,15); printf("\xDB\xDB\xDB\xDB\xB2 6. Edit Book's Record"); gotoxy(20,17); printf("\xDB\xDB\xDB\xDB\xB2 7. Close Application"); gotoxy(20,19); printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2"); gotoxy(20,20); t(); gotoxy(20,21); printf("Enter your choice:"); switch(getch()) { case '1': addbooks(); break; case '2': deletebooks(); break; case '3': searchbooks(); break; case '4': issuebooks(); break; case '5': viewbooks(); break; case '6': editbooks(); break; case '7': { system("cls"); gotoxy(16,3); printf("\tLibrary Management System"); gotoxy(16,4); printf("\tMini Project in C"); gotoxy(16,5); printf("******************************************"); gotoxy(16,10); printf("*******************************************"); gotoxy(16,11); printf("*******************************************"); gotoxy(16,13); printf("********************************************"); gotoxy(10,17); printf("Exiting in 3 second...........>"); //flushall(); Sleep(3000); exit(0); } default: { gotoxy(10,23); printf("\aWrong Entry!!Please re-entered correct option"); if(getch()) mainmenu(); } } } void addbooks(void) //funtion that add books { system("cls"); int i; gotoxy(20,5); printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2SELECT CATEGOIES\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2"); gotoxy(20,7); printf("\xDB\xDB\xDB\xDB\xB2 1. Computer"); gotoxy(20,9); printf("\xDB\xDB\xDB\xDB\xB2 2. Electronics"); gotoxy(20,11); printf("\xDB\xDB\xDB\xDB\xB2 3. Electrical"); gotoxy(20,13); printf("\xDB\xDB\xDB\xDB\xB2 4. Civil"); gotoxy(20,15); printf("\xDB\xDB\xDB\xDB\xB2 5. Mechanical"); gotoxy(20,17); printf("\xDB\xDB\xDB\xDB\xB2 6. Architecture"); gotoxy(20,19); printf("\xDB\xDB\xDB\xDB\xB2 7. Back to main menu"); gotoxy(20,21); printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2"); gotoxy(20,22); printf("Enter your choice:"); scanf("%d",&s); if(s==7) mainmenu() ; system("cls"); fp=fopen("Bibek.dat","ab+"); if(getdata()==1) { a.cat=catagories[s-1]; fseek(fp,0,SEEK_END); fwrite(&a,sizeof(a),1,fp); fclose(fp); gotoxy(21,14); printf("The record is sucessfully saved"); gotoxy(21,15); printf("Save any more?(Y / N):"); if(getch()=='n') mainmenu(); else system("cls"); addbooks(); } } void deletebooks() //function that delete items from file fp { system("cls"); int d; char another='y'; while(another=='y') //infinite loop { system("cls"); gotoxy(10,5); printf("Enter the Book ID to delete:"); scanf("%d",&d); fp=fopen("Bibek.dat","rb+"); rewind(fp); while(fread(&a,sizeof(a),1,fp)==1) { if(a.id==d) { gotoxy(10,7); printf("The book record is available"); gotoxy(10,8); printf("Book name is %s",a.name); gotoxy(10,9); printf("Rack No. is %d",a.rackno); findbook='t'; } } if(findbook!='t') { gotoxy(10,10); printf("No record is found modify the search"); if(getch()) mainmenu(); } if(findbook=='t' ) { gotoxy(10,9); printf("Do you want to delete it?(Y/N):"); if(getch()=='y') { ft=fopen("test.dat","wb+"); //temporary file for delete rewind(fp); while(fread(&a,sizeof(a),1,fp)==1) { if(a.id!=d) { fseek(ft,0,SEEK_CUR); fwrite(&a,sizeof(a),1,ft); //write all in tempory file except that } //we want to delete } fclose(ft); fclose(fp); remove("Bibek.dat"); rename("test.dat","Bibek.dat"); //copy all item from temporary file to fp except that fp=fopen("Bibek.dat","rb+"); //we want to delete if(findbook=='t') { gotoxy(10,10); printf("The record is sucessfully deleted"); gotoxy(10,11); printf("Delete another record?(Y/N)"); } } else mainmenu(); fflush(stdin); another=getch(); } } gotoxy(10,15); mainmenu(); } void searchbooks() { system("cls"); int d; printf("*****************************Search Books*********************************"); gotoxy(20,10); printf("\xDB\xDB\xDB\xB2 1. Search By ID"); gotoxy(20,14); printf("\xDB\xDB\xDB\xB2 2. Search By Name"); gotoxy( 15,20); printf("Enter Your Choice"); fp=fopen("Bibek.dat","rb+"); //open file for reading propose rewind(fp); //move pointer at the begining of file switch(getch()) { case '1': { system("cls"); gotoxy(25,4); printf("****Search Books By Id****"); gotoxy(20,5); printf("Enter the book id:"); scanf("%d",&d); gotoxy(20,7); printf("Searching........"); while(fread(&a,sizeof(a),1,fp)==1) { if(a.id==d) { Sleep(2); gotoxy(20,7); printf("The Book is available"); gotoxy(20,8); printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2"); gotoxy(20,9); printf("\xB2 ID:%d",a.id);gotoxy(47,9);printf("\xB2"); gotoxy(20,10); printf("\xB2 Name:%s",a.name);gotoxy(47,10);printf("\xB2"); gotoxy(20,11); printf("\xB2 Author:%s ",a.Author);gotoxy(47,11);printf("\xB2"); gotoxy(20,12); printf("\xB2 Qantity:%d ",a.quantity);gotoxy(47,12);printf("\xB2"); gotoxy(47,11);printf("\xB2"); gotoxy(20,13); printf("\xB2 Price:Rs.%.2f",a.Price);gotoxy(47,13);printf("\xB2"); gotoxy(20,14); printf("\xB2 Rack No:%d ",a.rackno);gotoxy(47,14);printf("\xB2"); gotoxy(20,15); printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2"); findbook='t'; } } if(findbook!='t') //checks whether conditiion enters inside loop or not { gotoxy(20,8); printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2"); gotoxy(20,9);printf("\xB2"); gotoxy(38,9);printf("\xB2"); gotoxy(20,10); printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2"); gotoxy(22,9);printf("\aNo Record Found"); } gotoxy(20,17); printf("Try another search?(Y/N)"); if(getch()=='y') searchbooks(); else mainmenu(); break; } case '2': { char s[15]; system("cls"); gotoxy(25,4); printf("****Search Books By Name****"); gotoxy(20,5); printf("Enter Book Name:"); scanf("%s",s); int d=0; while(fread(&a,sizeof(a),1,fp)==1) { if(strcmp(a.name,(s))==0) //checks whether a.name is equal to s or not { gotoxy(20,7); printf("The Book is available"); gotoxy(20,8); printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2"); gotoxy(20,9); printf("\xB2 ID:%d",a.id);gotoxy(47,9);printf("\xB2"); gotoxy(20,10); printf("\xB2 Name:%s",a.name);gotoxy(47,10);printf("\xB2"); gotoxy(20,11); printf("\xB2 Author:%s",a.Author);gotoxy(47,11);printf("\xB2"); gotoxy(20,12); printf("\xB2 Qantity:%d",a.quantity);gotoxy(47,12);printf("\xB2"); gotoxy(20,13); printf("\xB2 Price:Rs.%.2f",a.Price);gotoxy(47,13);printf("\xB2"); gotoxy(20,14); printf("\xB2 Rack No:%d ",a.rackno);gotoxy(47,14);printf("\xB2"); gotoxy(20,15); printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2"); d++; } } if(d==0) { gotoxy(20,8); printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2"); gotoxy(20,9);printf("\xB2"); gotoxy(38,9);printf("\xB2"); gotoxy(20,10); printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2"); gotoxy(22,9);printf("\aNo Record Found"); } gotoxy(20,17); printf("Try another search?(Y/N)"); if(getch()=='y') searchbooks(); else mainmenu(); break; } default : getch(); searchbooks(); } fclose(fp); } void issuebooks(void) //function that issue books from library { int t; system("cls"); printf("********************************ISSUE SECTION**************************"); gotoxy(10,5); printf("\xDB\xDB\xDB\xDb\xB2 1. Issue a Book"); gotoxy(10,7); printf("\xDB\xDB\xDB\xDb\xB2 2. View Issued Book"); gotoxy(10,9); printf("\xDB\xDB\xDB\xDb\xB2 3. Search Issued Book"); gotoxy(10,11); printf("\xDB\xDB\xDB\xDb\xB2 4. Remove Issued Book"); gotoxy(10,14); printf("Enter a Choice:"); switch(getch()) { case '1': //issue book { system("cls"); int c=0; char another='y'; while(another=='y') { system("cls"); gotoxy(15,4); printf("***Issue Book section***"); gotoxy(10,6); printf("Enter the Book Id:"); scanf("%d",&t); fp=fopen("Bibek.dat","rb"); fs=fopen("Issue.dat","ab+"); if(checkid(t)==0) //issues those which are present in library { gotoxy(10,8); printf("The book record is available"); gotoxy(10,9); printf("There are %d unissued books in library ",a.quantity); gotoxy(10,10); printf("The name of book is %s",a.name); gotoxy(10,11); printf("Enter student name:"); scanf("%s",a.stname); //struct dosdate_t d; //for current date //_dos_getdate(&d); //a.issued.dd=d.day; //a.issued.mm=d.month; //a.issued.yy=d.year; gotoxy(10,12); printf("Issued date=%d-%d-%d",a.issued.dd,a.issued.mm,a.issued.yy); gotoxy(10,13); printf("The BOOK of ID %d is issued",a.id); a.duedate.dd=a.issued.dd+RETURNTIME; //for return date a.duedate.mm=a.issued.mm; a.duedate.yy=a.issued.yy; if(a.duedate.dd>30) { a.duedate.mm+=a.duedate.dd/30; a.duedate.dd-=30; } if(a.duedate.mm>12) { a.duedate.yy+=a.duedate.mm/12; a.duedate.mm-=12; } gotoxy(10,14); printf("To be return:%d-%d-%d",a.duedate.dd,a.duedate.mm,a.duedate.yy); fseek(fs,sizeof(a),SEEK_END); fwrite(&a,sizeof(a),1,fs); fclose(fs); c=1; } if(c==0) { gotoxy(10,11); printf("No record found"); } gotoxy(10,15); printf("Issue any more(Y/N):"); fflush(stdin); another=getche(); fclose(fp); } break; } case '2': //show issued book list { system("cls"); int j=4; printf("*******************************Issued book list*******************************\n"); gotoxy(2,2); printf("STUDENT NAME CATEGORY ID BOOK NAME ISSUED DATE RETURN DATE"); fs=fopen("Issue.dat","rb"); while(fread(&a,sizeof(a),1,fs)==1) { gotoxy(2,j); printf("%s",a.stname); gotoxy(18,j); printf("%s",a.cat); gotoxy(30,j); printf("%d",a.id); gotoxy(36,j); printf("%s",a.name); gotoxy(51,j); printf("%d-%d-%d",a.issued.dd,a.issued.mm,a.issued.yy ); gotoxy(65,j); printf("%d-%d-%d",a.duedate.dd,a.duedate.mm,a.duedate.yy); //struct dosdate_t d; //_dos_getdate(&d); gotoxy(50,25); // printf("Current date=%d-%d-%d",d.day,d.month,d.year); j++; } fclose(fs); gotoxy(1,25); returnfunc(); } break; case '3': //search issued books by id { system("cls"); gotoxy(10,6); printf("Enter Book ID:"); int p,c=0; char another='y'; while(another=='y') { scanf("%d",&p); fs=fopen("Issue.dat","rb"); while(fread(&a,sizeof(a),1,fs)==1) { if(a.id==p) { issuerecord(); gotoxy(10,12); printf("Press any key......."); getch(); issuerecord(); c=1; } } fflush(stdin); fclose(fs); if(c==0) { gotoxy(10,8); printf("No Record Found"); } gotoxy(10,13); printf("Try Another Search?(Y/N)"); another=getch(); } } break; case '4': //remove issued books from list { system("cls"); int b; FILE *fg; //declaration of temporary file for delete char another='y'; while(another=='y') { gotoxy(10,5); printf("Enter book id to remove:"); scanf("%d",&b); fs=fopen("Issue.dat","rb+"); while(fread(&a,sizeof(a),1,fs)==1) { if(a.id==b) { issuerecord(); findbook='t'; } if(findbook=='t') { gotoxy(10,12); printf("Do You Want to Remove it?(Y/N)"); if(getch()=='y') { fg=fopen("record.dat","wb+"); rewind(fs); while(fread(&a,sizeof(a),1,fs)==1) { if(a.id!=b) { fseek(fs,0,SEEK_CUR); fwrite(&a,sizeof(a),1,fg); } } fclose(fs); fclose(fg); remove("Issue.dat"); rename("record.dat","Issue.dat"); gotoxy(10,14); printf("The issued book is removed from list"); } } if(findbook!='t') { gotoxy(10,15); printf("No Record Found"); } } gotoxy(10,16); printf("Delete any more?(Y/N)"); another=getch(); } } default: gotoxy(10,18); printf("\aWrong Entry!!"); getch(); issuebooks(); break; } gotoxy(1,30); returnfunc(); } void viewbooks(void) //show the list of book persists in library { int i=0,j; system("cls"); gotoxy(1,1); printf("*********************************Book List*****************************"); gotoxy(2,2); printf(" CATEGORY ID BOOK NAME AUTHOR QTY PRICE RackNo "); j=4; fp=fopen("Bibek.dat","rb"); while(fread(&a,sizeof(a),1,fp)==1) { gotoxy(3,j); printf("%s",a.cat); gotoxy(16,j); printf("%d",a.id); gotoxy(22,j); printf("%s",a.name); gotoxy(36,j); printf("%s",a.Author); gotoxy(50,j); printf("%d",a.quantity); gotoxy(57,j); printf("%.2f",a.Price); gotoxy(69,j); printf("%d",a.rackno); printf("\n\n"); j++; i=i+a.quantity; } gotoxy(3,25); printf("Total Books =%d",i); fclose(fp); gotoxy(35,25); returnfunc(); } void editbooks(void) //edit information about book { system("cls"); int c=0; int d,e; gotoxy(20,4); printf("****Edit Books Section****"); char another='y'; while(another=='y') { system("cls"); gotoxy(15,6); printf("Enter Book Id to be edited:"); scanf("%d",&d); fp=fopen("Bibek.dat","rb+"); while(fread(&a,sizeof(a),1,fp)==1) { if(checkid(d)==0) { gotoxy(15,7); printf("The book is availble"); gotoxy(15,8); printf("The Book ID:%d",a.id); gotoxy(15,9); printf("Enter new name:");scanf("%s",a.name); gotoxy(15,10); printf("Enter new Author:");scanf("%s",a.Author); gotoxy(15,11); printf("Enter new quantity:");scanf("%d",&a.quantity); gotoxy(15,12); printf("Enter new price:");scanf("%f",&a.Price); gotoxy(15,13); printf("Enter new rackno:");scanf("%d",&a.rackno); gotoxy(15,14); printf("The record is modified"); fseek(fp,ftell(fp)-sizeof(a),0); fwrite(&a,sizeof(a),1,fp); fclose(fp); c=1; } if(c==0) { gotoxy(15,9); printf("No record found"); } } gotoxy(15,16); printf("Modify another Record?(Y/N)"); fflush(stdin); another=getch() ; } returnfunc(); } void returnfunc(void) { { printf(" Press ENTER to return to main menu"); } a: if(getch()==13) //allow only use of enter mainmenu(); else goto a; } int getdata() { int t; gotoxy(20,3);printf("Enter the Information Below"); gotoxy(20,4);printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2"); gotoxy(20,5); printf("\xB2");gotoxy(46,5);printf("\xB2"); gotoxy(20,6); printf("\xB2");gotoxy(46,6);printf("\xB2"); gotoxy(20,7); printf("\xB2");gotoxy(46,7);printf("\xB2"); gotoxy(20,8); printf("\xB2");gotoxy(46,8);printf("\xB2"); gotoxy(20,9); printf("\xB2");gotoxy(46,9);printf("\xB2"); gotoxy(20,10); printf("\xB2");gotoxy(46,10);printf("\xB2"); gotoxy(20,11); printf("\xB2");gotoxy(46,11);printf("\xB2"); gotoxy(20,12); printf("\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2\xB2"); gotoxy(21,5); printf("Category:"); gotoxy(31,5); printf("%s",catagories[s-1]); gotoxy(21,6); printf("Book ID:\t"); gotoxy(30,6); scanf("%d",&t); if(checkid(t) == 0) { gotoxy(21,13); printf("\aThe book id already exists\a"); getch(); mainmenu(); return 0; } a.id=t; gotoxy(21,7); printf("Book Name:");gotoxy(33,7); scanf("%s",a.name); gotoxy(21,8); printf("Author:");gotoxy(30,8); scanf("%s",a.Author); gotoxy(21,9); printf("Quantity:");gotoxy(31,9); scanf("%d",&a.quantity); gotoxy(21,10); printf("Price:");gotoxy(28,10); scanf("%f",&a.Price); gotoxy(21,11); printf("Rack No:");gotoxy(30,11); scanf("%d",&a.rackno); return 1; } int checkid(int t) //check whether the book is exist in library or not { rewind(fp); while(fread(&a,sizeof(a),1,fp)==1) if(a.id==t) return 0; //returns 0 if book exits return 1; //return 1 if it not } int t(void) //for time { time_t t; time(&t); printf("Date and time:%s\n",ctime(&t)); return 0 ; } /*void show_mouse(void) //show inactive mouse pointer in programme { union REGS in,out; in.x.ax = 0x1; int86(0x33,&in,&out); }*/ void Password(void) //for password option { mainmenu(); } void issuerecord() //display issued book's information { system("cls"); gotoxy(10,8); printf("The Book has taken by Mr. %s",a.stname); gotoxy(10,9); printf("Issued Date:%d-%d-%d",a.issued.dd,a.issued.mm,a.issued.yy); gotoxy(10,10); printf("Returning Date:%d-%d-%d",a.duedate.dd,a.duedate.mm,a.duedate.yy); } /*void loaderanim() { int loader; system("cls"); gotoxy(20,10); printf("LOADING........"); printf("\n\n"); gotoxy(22,11); for(loader=1;loader<20;loader++) { Sleep(100);printf("%c",219);} }*/ //End of program |
Run Quick Virus Scan for secure Download
Run Quick Scan for safe DownloadDownloadable Source Code
Summary
This System Project is being develop in C programming language, and this simple project can enhance the knowledge of the beginners or the students to develop their skills in programming, also this project is easy to understand the module and their variables.
Related Articles
- Library Management System Project In Python and MySQL
- Simple Hospital Management System In C With Source Code
- Library Management System Project in VB.Net With Source Code
- Online Library Management System in PHP Source Code
Inquiries
If you have any questions or suggestions about Library Management System In C , please feel free to leave a comment below.