BookTracker

BookTracker

📝Building a Simple Library Management System Using C

In the world of software development, creating practical applications is a great way to improve programming skills. One such application is a Library Management System, which I developed using C programming. The system allows users to manage books, track issuance and maintain a record of both available and issued books.

Features of the Library Management System:

🚀Add Books: Users can add new books to the system, providing details like book ID, name and author.

🚀View Books List: A list of all available books can be viewed, displaying key information such as book ID, name, author and the date the book was added.

🚀Remove Books: If a book is no longer needed, it can be removed from the librarys record.

🚀Issue Books: Students can borrow books, with the system recording the students name, class, roll number, book issued and the issue date.

🚀Issued Books List: View a detailed list of all books that have been issued to students, including student details.

👉How It Works:

The system relies on file handling for persistent data storage. Information about books and issued books is stored in text files. Whenever a user adds, removes, or issues a book, the data is read from or written to these files.

📌The key functions in the system include:

•Adding Books: When a new book is added, its stored in a file (books.txt). Each book entry includes the book ID, name, author, and the current date.

•Removing Books: Books can be deleted from the librarys record based on their ID. The system creates a temporary file and writes all books except the one to be removed.

•Issuing Books: When a book is issued, the students details (name, class, roll number) are saved along with the book information in another file (issue.txt).

•Listing Issued Books: Users can view all issued books, with detailed student and book information.

💡Why Is This Useful?

Practice with File Handling: The system demonstrates how to work with files in C, such as opening, reading, writing, and closing files. This is an important skill for any programmer.

Real-World Application: A Library Management System is a common real-world problem that can be solved with simple data structures and file management.

Enhancing Problem-Solving Skills: This project improves your ability to think logically about how data should be stored, manipulated, and retrieved.

🎯The Code in Action:

This simple program uses fopen(), fwrite(), fread(), and fclose() functions to read and write data into files, and time.h to automatically record the date whenever a book is added or issued. The system provides a menu interface where users can choose different operations such as adding books, viewing available books, issuing books and viewing the list of issued books.

🔗Why I Built This:

I built this Library Management System to practice file handling, structure usage, and date management in C. Its a great starting project for anyone new to C programming, as it teaches you how to handle data efficiently while also creating something useful.

If your are a C programming beginner, I highly recommend trying this project. Not only will it improve your coding skills, but its also a great way to learn more about managing data in a real-world application

♨️CODE

#include<stdio.h>

#include<stdlib.h>

#include<time.h>

struct books{

int id;

char bookName[50];

char authorName[50];

char date[12];

}b;

struct student{

int id;

char sName[50];

char sClass[50];

int sRoll;

char bookName[50];

char date[12];

}s;

FILE *fp;

int main(){

int ch;

while(1){

system("cls");

printf("<== Library Management System ==>\n");

printf("1.Add Book\n");

printf("2.Books List\n");

printf("3.Remove Book\n");

printf("4.Issue Book\n");

printf("5.Issued Book List\n");

printf("0.Exit\n\n");

printf("Enter your choice: ");

scanf("%d", &ch);

switch(ch){

case 0:exit(0);

case 1:addBook();

break;

case 2:booksList();

break;

case 3:del();

break;

case 4:issueBook();

break;

case 5: issueList();

break;

default:printf("Invalid Choice...\n\n");

}

printf("Press Any Key To Continue...");

getch();

}

return 0;

}

void addBook(){

char myDate[12];

time_t t = time(NULL);

struct tm tm = *localtime(&t);

sprintf(myDate, "%02d/%02d/%d", tm.tm_mday, tm.tm_mon+1, tm.tm_year + 1900);

strcpy(b.date, myDate);

fp = fopen("books.txt", "ab");

printf("Enter book id: ");

scanf("%d", &b.id);

printf("Enter book name: ");

fflush(stdin);

gets(b.bookName);

printf("Enter author name: ");

fflush(stdin);

gets(b.authorName);

printf("Book Added Successfully");

fwrite(&b, sizeof(b), 1, fp);

fclose(fp);

}

void booksList(){

system("cls");

printf("<== Available Books ==>\n\n");

printf("%-10s %-30s %-20s %s\n\n", "Book id", "Book Name Author", "Date");

fp = fopen("books.txt", "rb");

while(fread(&b, sizeof(b), 1, fp) == 1){

printf("%-10d %-30s %-20s %s\n", b.id, b.bookName, b.authorName, b.date);

}

💻OUTPUT-

<== Library Management System ==>

1. Add Book

2. Books List

3. Remove Book

4. Issue Book

5. Issued Book List

0. Exit

Enter your choice: 3

Enter Book id to remove: 102

Deleted Successfully.

Press Enter to continue...

<== Library Management System ==>

1. Add Book

2. Books List

3. Remove Book

4. Issue Book

5. Issued Book List

0. Exit

Enter your choice: 2

<== Available Books ==>

Book id Book Name Author Date

101 C Programming Dennis Ritchie 07/03/2025

Press Enter to continue...

<== Library Management System ==>

1. Add Book

2. Books List

3. Remove Book

4. Issue Book

5. Issued Book List

0. Exit

Enter your choice: 4

Enter Book id to issue: 101

Enter Student Name: John Doe

Enter Student Class: 10th Grade

Enter Student Roll: 25

Book Issued Successfully

Press Enter to continue...

<== Library Management System ==>

1. Add Book

2. Books List

3. Remove Book

4. Issue Book

5. Issued Book List

0. Exit

Enter your choice: 5

<== Book Issue List ==>

S.id Name Class Roll Book Name Date

101 John Doe 10th Grade 25 C Programming 07/03/2025

Press Enter to continue...

<== Library Management System ==>

1. Add Book

2. Books List

3. Remove Book

4. Issue Book

5. Issued Book List

0. Exit

Enter your choice: 0

(Program exits)

conclusion:

The above code implements a simple Library Management System in C that allows users to manage books in a library. It provides features to add books, list available books, remove books, issue books, and view issued books. The program utilizes file handling to store book information in a file (books.txt). It also incorporates basic date handling to record when a book is added. However, certain functions like removing books, issuing books, and listing issued books are not fully implemented in the code provided. The system offers a text-based menu interface for the user to interact with the library database.

I should thankful to my teammates Akshaya Ammuloju , RAMA SIRI , Hepshiba Bammidi

Kowsalya Beela ,G.Shakina Madhuri, Arpitha Danguria.

Grateful to HOD mam Dr.p.vijaya Bharathi and Dean placements sir Dr.manendra sai dasari and to my mentor Dinesh kumar Thangavel for helping me to publish this article.

To view or add a comment, sign in

Others also viewed

Explore content categories