An example Analysis of the implementation of Library Management system in C language
This article will explain in detail the example analysis of the implementation of the library management system in C language. The editor thinks it is very practical, so I share it for you as a reference. I hope you can get something after reading this article.
The details are as follows
Experimental requirements:
1. Book information: including ISBN, title, editor-in-chief, publisher, pricing
2. Function:
(1) insert: if there is no new book information in the table (different ISBN), insert the new book information (at the end of the table).
(2) Delete: press ISBN to delete
(3) search: search by ISBN
(4) modify: press ISBN to find, and then modify each attribute
(5) sorting: sort by ISBN
(6) count: the number of books output.
(7) Import: read existing book information from TXT file (different attributes are separated by tab key)
(8) Save: save the existing information in the table to a txt file
(9) print: display all book information on the screen
3. Expand the function (optional):
(1) add search by title, chief editor and publishing house
(2) increase the order by title, editor-in-chief, publishing house and pricing
4. Interface requirements: simple human-computer interface
# include # include # include / / header file # define OK 1#define ERROR 0#define OVERFLOW-1#define LIST_INIT_SIZE 50#define LISTINCREMENT 10 / / Macro definition, that is, defining the constant typedef int status;typedef struct {char ISBN [15]; char bookname [30]; char writername [10]; char publisher [20]; float price;} ElemType;typedef struct {ElemType * elem; int length; int listsize;} SqList / / defines the structure type, that is, the typedef type name status InitList_Sq (SqList & L) {/ / constructs an empty linear table L. L.eleme = (ElemType *) malloc (LIST_INIT_SIZE*sizeof (ElemType)); / / apply for memory if (! L.elem) of initialization length {/ / if the sequence of L is not empty exit (OVERFLOW); / / indicates that L is redefined and that an overflow} L.room0 is thrown; / / there are 0 elements L.listsize=LIST_INIT_SIZE in the default L. / / the capacity of the default L is the initialization length return OK;} int LocateElem_Sq (SqList LMagnechar ISBN []) {/ / traversing in the order table L to find the order of the first element whose value is equal to e.ISBN. If found, return its order, otherwise return 0 For {newbase = (ElemType*) realloc (L.elem, (L.listsize+LISTINCREMENT) * sizeof (ElemType)); if (! newbase) {exit (OVERFLOW);} L.LISTINCRENTS;} L.elem [L.length] = e; L.LISTINCRENTS; return OK } status ListDelete_Sq (SqList & L ISBN ISBN [], ElemType & e) {/ / delete the element of ISBN in L and return the deleted element Int iMagnej; if ((i=LocateElem_Sq (LMagneISBN)) = = 0) {return ERROR;} e = L.eleme [I-1]; for