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;
}