T.T nvm, ok
*all the username and password of the librarian is stored in file called''Librarian_ID.txt"
* Librarian_ID.txt
--> Username (max length = 30 chars )
--> Password ( max length = 30 chars )
and below is a function to let me test is it work.
Code:
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
void librarian_module ( );
int main ( void )
{
FILE* lib_login_pass;
char username [ 9 ];
char password [ 9 ];
char lib_username [ 9 ];
char lib_password [ 9 ];
lib_login_pass = fopen("Librarian_ID.txt", "r" );
if ( !lib_login_pass)
{
printf("Could not open file\a\n" );
exit (101);
}
printf("Please enter the following: \n");
printf("Username: ");
scanf(" %s", username);
printf("Password: ");
scanf(" %s", password);
while ( fscanf ( lib_login_pass, " %s %s", lib_username, lib_password ) == 2 )
{
if ( username == lib_username )
{
if ( password == lib_password )
{
librarian_module ( );
break;
}
}
else
printf("Wrong username or password!\n");
}
return 0;
}
void librarian_module ( )
{
printf("successful\n");
return;
}