Monday, June 3, 2024

Part 3: Library management in C| Read Comma Separated Values (CSV) file and Student Login System

Previous Page                                                                                                                           Next Page

In this application we have two scenarios where we read CSV files. First to read Students data and second to read books data. Students need to provide student id to login application. We read the students data from csv file and compare the student id. Also, we read large set of books data from csv file.

Sample student csv data:

Sample books csv data:

The header file loadCsvData.h is written to load csv files student data and books data. There are four main functions which reads the files.

static int getStudentID(char stuId[MAX_ID], struct stuProfile *st);
static int  loadStuValues(char *line, char *sFields[STU_COL_NUM]);
int readBooks();
static int  loadBookValues(char *line, char *lFields[BK_COL_NUM]);
int getRowCount(FILE *fpl);

Part 2: Library management in C | username/password login system and manage admin accounts

Previous Page                                                                                                                              Next Page

In this part, we will learn the techniques to implement a username and password login system and manage user accounts.

When a user runs the application for the first time in admin mode, the application requests the user to create an admin account. However, from the second run onwards, the user has to log in using their account details. After logging into admin mode, the user can add or modify multiple admin accounts. To identify the application’s first run, it will check if the admin account file exists in the system. If the file doesn’t exist, then the application calls the create account function. Otherwise, if the file exists, it will call the Admin login function.

int checkFirstLogin(){
    int flag=1;

    fa = fopen(DATA_FILE,"rb");

    if(fa!= NULL){
        flag= 0;

    return flag;


Part 4: Library management in C| Pagination, Dynamic Memory allocation, write Comma Separated Values (CSV) file

Previous Page

In this part, we will create pagination in C programming to view large set of books data. In college there might be thousands of books. We can't display all items on the screen, so we need to create techniques to display small set of data at a time and allow users to select next page or previous page to view data which is called pagination. Also, we will discuss to manage large set of books data and write books data into CSV file.

Here, we will discuss following items:

  • Pagination: Users can explore large set of data by selecting next or previous page of data.
  • Dynamic Memory allocation: Dynamic numbers of books are loaded into the memory, modify or delete book details from the memory using dynamic memory allocation.
  • Write Comma Separated Values (CSV): Export large set of books data into CSV file.
Please follow the source code of header file userMenu.h and loadCsvData.h. 

We have three main functions to implement pagination features. The main technique is to load data into computer memory (RAM). The number of data which can be loaded in memory depend upon size of the memory. However, we will not get memory problem to load couple of thousands of data. In this application I haven't used large set of data however this technique can be used for any size of data.
The name of the functions are readBooks(), viewAllBooks(), and viewBooksByPage().  

Part 1: Library management in C | Flowchart and Function Stack Call Diagram

Previous Page                                                                                                                            Next Page

The application is represented by three mainMenu, adminMenu and studentMenu flowchart. The mainMenu flowchart represents the options provided to the user to choose application mode and user security. The adminMenu flowchart represents the all the tasks that administrator can perform, and the studentMenu flowchart represents the tasks that students can perform.

Main Menu flowchart