In this section, we will discuss the following items.
- Techniques to change direction of the snake based on user input.
- Techniques to calculate the snake's next position.
- Techniques to check for snake collision with window and its body.
Download Mini project in c,c++,c# ,OpenGL,GLUT,GLFW,windows form application source code
In this section, we will discuss the following items.
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:
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;
}
fclose(fa);
return flag;
}
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:
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);
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.
If you remember we have categoried all the functions into two types user functions and operational functions. Here I will explain the operational function and its usage in user functions one by one.
First, let's define Variables and Data Structure.
// Define Constant Variables
#define ESC 27
#define MAX_NAME_SZ 15
#define MAX_NUM_SZ 25
#define READ_ARRAY_SZ 15
#define DATA_FILE "dataFile.dat"
#define TEMP_FILE "tempFile.dat"
//Define data structure
struct data{
char fName[MAX_NAME_SZ];
char lName[MAX_NAME_SZ];
char mPhone[MAX_NUM_SZ];
char wPhone[MAX_NUM_SZ];
char hPhone[MAX_NUM_SZ];
};