Library Management System project is developed using VB.NET. The Project is based on the concept of managing book records. Talking about the project, it contains lots of features. A user can manage all the records, such as borrowed, return books, history, reader, users etc.
Features:
- User Management
- Borrow books, history, return books
- Manage reader
- Manage books
- Generate report
Download Library Management System project is developed using VB.NET
A Library Management System (LMS) is a project to manage book inventory, issue/return records, and users in a library. Below is a simple C program for an LMS with basic functionality:
Features:
- Add a Book: Add a book to the library database.
- Display Books: Show all available books in the library.
- Issue a Book: Issue a book to a user.
- Return a Book: Return a book to the library.
- Exit: Save and exit the program.
Source Code
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_BOOKS 100
#define TITLE_LEN 50
#define AUTHOR_LEN 50
typedef struct {
char title[TITLE_LEN];
char author[AUTHOR_LEN];
int id;
int isIssued; // 0 = Available, 1 = Issued
} Book;
Book books[MAX_BOOKS];
int totalBooks = 0;
void addBook() {
if (totalBooks >= MAX_BOOKS) {
printf("Library is full! Cannot add more books.\n");
return;
}
printf("Enter Book ID: ");
scanf("%d", &books[totalBooks].id);
printf("Enter Book Title: ");
scanf(" %[^\n]", books[totalBooks].title);
printf("Enter Author Name: ");
scanf(" %[^\n]", books[totalBooks].author);
books[totalBooks].isIssued = 0; // Initially available
totalBooks++;
printf("Book added successfully!\n");
}
void displayBooks() {
if (totalBooks == 0) {
printf("No books in the library.\n");
return;
}
printf("\nList of Books in the Library:\n");
printf("----------------------------------------------------\n");
printf("ID\tTitle\t\t\tAuthor\t\t\tStatus\n");
printf("----------------------------------------------------\n");
for (int i = 0; i < totalBooks; i++) {
printf("%d\t%-20s\t%-20s\t%s\n", books[i].id, books[i].title, books[i].author,
books[i].isIssued ? "Issued" : "Available");
}
printf("----------------------------------------------------\n");
}
void issueBook() {
int bookId, found = 0;
printf("Enter the Book ID to issue: ");
scanf("%d", &bookId);
for (int i = 0; i < totalBooks; i++) {
if (books[i].id == bookId) {
found = 1;
if (books[i].isIssued == 1) {
printf("Book is already issued.\n");
} else {
books[i].isIssued = 1;
printf("Book issued successfully!\n");
}
break;
}
}
if (!found) {
printf("Book not found.\n");
}
}
void returnBook() {
int bookId, found = 0;
printf("Enter the Book ID to return: ");
scanf("%d", &bookId);
for (int i = 0; i < totalBooks; i++) {
if (books[i].id == bookId) {
found = 1;
if (books[i].isIssued == 0) {
printf("Book is not issued.\n");
} else {
books[i].isIssued = 0;
printf("Book returned successfully!\n");
}
break;
}
}
if (!found) {
printf("Book not found.\n");
}
}
void saveToFile() {
FILE *file = fopen("library.dat", "wb");
if (file == NULL) {
printf("Error saving data.\n");
return;
}
fwrite(&totalBooks, sizeof(int), 1, file);
fwrite(books, sizeof(Book), totalBooks, file);
fclose(file);
printf("Library data saved successfully!\n");
}
void loadFromFile() {
FILE *file = fopen("library.dat", "rb");
if (file != NULL) {
fread(&totalBooks, sizeof(int), 1, file);
fread(books, sizeof(Book), totalBooks, file);
fclose(file);
}
}
int main() {
int choice;
loadFromFile();
do {
printf("\nLibrary Management System\n");
printf("1. Add Book\n");
printf("2. Display Books\n");
printf("3. Issue Book\n");
printf("4. Return Book\n");
printf("5. Exit\n");
printf("Enter your choice: ");
scanf("%d", &choice);
switch (choice) {
case 1:
addBook();
break;
case 2:
displayBooks();
break;
case 3:
issueBook();
break;
case 4:
returnBook();
break;
case 5:
saveToFile();
printf("Exiting the program. Goodbye!\n");
break;
default:
printf("Invalid choice. Please try again.\n");
}
} while (choice != 5);
return 0;
}
Key Features:
- Persistent Storage: Library data is saved in
library.dat
and loaded automatically at startup. - Menu-Driven Interface: Simplifies user interaction.
- Basic Functionalities: Adding, displaying, issuing, and returning books.
Compilation and Execution:
- Save the code in a file named
library_management.c
. - Compile it using:
gcc library_management.c -o library_management
- Run the program:
./library_management
Potential Enhancements:
- Search Functionality: Allow searching by title or author.
- Advanced Status: Track who issued the book and due dates.
- Sorting: Display books sorted by title, author, or ID.
- Graphical Interface: Use a library like GTK for GUI.
This implementation provides a solid foundation for a library management system in C.