Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- *Progamer's Name: Dillon Bong Zi Hang
- *Program Description: Library Management System Login Menu
- *Last Updated: 22 - January - 2016
- */
- // Header File
- #include"LMS_Header.h"
- /* Library Management System Login Menu */
- int main(void)
- {
- // Label A for invalid input in Login
- A:
- // Get username and password
- printf("***********************************************\n");
- printf("* Library Management System *\n");
- printf("***********************************************\n\n");
- printf("Username: ");
- scanf("%s", &u);
- printf("\nPassword: ");
- scanf("%s", &p);
- // Entered username and password is equal to Admin
- if ((stricmp(username, u)) == 0 && (strcmp(password, p)) == 0)
- {
- // Login success from login menu. Go to Main Menu
- {
- printf("\nLogin Successful\n\n");
- system("pause");
- system("cls");
- }
- /* Library Management System Main Menu */
- {
- // Loop While num1 equals to zero
- while (num1 == 0)
- {
- printf("***********************************************\n");
- printf("* Main Menu *\n");
- printf("***********************************************\n\n");
- printf("1. Add New Book\n");
- printf("2. Modify Book Details\n");
- printf("3. Remove Book\n");
- printf("4. View Book List\n");
- printf("5. Book Check In\n");
- printf("6. Book Check Out\n");
- printf("7. Search Menu\n");
- printf("8. View Logs\n");
- printf("9. Exit\n\n");
- {
- // Gets user's option and check for errors
- printf("Please select an option: ");
- fgets(main_menu_option, 63, stdin);
- }
- /* If the string is less than 1 or more than 2, then display the error */
- if (strlen(main_menu_option) < 1 || strlen(main_menu_option) > 2)
- {
- printf("\nInvalid length input please re-enter an option\n\n");
- system("pause>nul");
- system("cls");
- continue;
- }
- /* If the string entered does not equal to integer data type, then display the error */
- if (sscanf(main_menu_option, "%d", &num1) != 1)
- {
- num1 = 0;
- printf("\nInvalid data type input please re-enter an option\n\n");
- system("pause>nul");
- system("cls");
- continue;
- }
- /* if the integer is smaller than 1 or 9, then display the error */
- if (num1 < 1 || num1 > 9)
- {
- num1 = 0;
- printf("\nInvalid integer range input please re-enter an option\n\n");
- system("pause>nul");
- system("cls");
- continue;
- }
- switch (main_menu_option[63])
- {
- case '1':
- printf("Monday");
- break;
- case '2':
- printf("Tuesday");
- break;
- case '3':
- printf("");
- break;
- case '4':
- printf("");
- break;
- case '5':
- printf("");
- break;
- case '6':
- printf("");
- break;
- case '7':
- printf("");
- break;
- case '8':
- printf("");
- break;
- case '9':
- system("pause");
- return 0;
- break;
- }
- }
- }
- }
- else
- {
- // Login failed from login menu. Re-enter username and password
- printf("\nLogin Failed\n\n");
- system("pause");
- system("cls");
- goto A;
- }
- system("pause>nul");
- return 0;
- _getch();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement