Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

How to realize the File Database of Library Management system in C language

2025-04-07 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

In this article, the editor introduces in detail "how C language realizes the file database of book management system". The content is detailed, the steps are clear, and the details are handled properly. I hope that this article "how to realize the file database of the book management system in C language" can help you solve your doubts.

Topic requirement

Simple document Database-simulated Library Management system

Knowledge points involved: file reading and writing, memory management, structure definition, basic data structure, advanced formatting input and output

Request:

Write a program to simulate the library management system. Users are divided into two categories: administrators and readers, which display different text format menus and select the corresponding numbers through the menu items. The reader menu includes functions such as borrowing books, returning books, inquiring and so on. The administrator menu includes the entry, modification and deletion of book and reader information. Book information should at least include: number, book title, quantity, reader information should at least include: number, name, borrowed book. You can query the book information according to the book name or number, and you can find out which readers have borrowed a book.

The command line parameters are as follows:

Libsim-a (- u) xxxx

The first parameter is the executable program name; the second parameter is the user identity,-a represents the administrator,-u represents the reader, and the third parameter is the user name

Realized function

1. Administrator:

Manage books: add books, modify book names and quantities, and delete books.

Manage readers: add readers, change their names, and delete readers.

Click to view all book information (serial number, title, remaining number)

Click to view all reader information (serial number, reader name, borrowed books)

Query the details of a single book: you can look it up according to the serial number and title, and show the book serial number, name, remaining quantity and readers who have borrowed the book to the administrator.

2. Readers:

Borrow books (only one book can be borrowed at the same time)

Return the book

Click to view all book information (serial number, title, remaining number)

Readme

You need to run the program from the cmd command line, as shown in the figure (note the format)

Administrator name: Zhang

Enter the administrator menu format: executable program name-a Zhang (only one administrator is set, no administrator function is added)

Enter the reader menu format: executable program name-u reader name (you need to add readers through the administrator first)

The default generated files are placed in the root directory of the d disk (sometimes the intermediate transition files may not be deleted)

Book.txt: store book information

Users.txt: store reader information

The code # include#include int bookNumber = 1; / / the global variable indicates the serial number of the book int usersNumber = 1; / / indicates the reader number char enter; / / receives the newline character / / the function void addBook (FILE * Book) {FILE * Book1; / / needs to create a new file to change the information int judgeName = 0 when both the file and the book exist; / / determine whether the book has been stored int num = 1, readNum, readNumber / / number of books stored the number of books read char name [20] = {0}, readName [20] = {0}; / / stored the name of the book temporarily stored in the string name printf ("Please enter the name of the book to be added:"); for (int I = 0; I

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 206

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report