Advertisement
Guest User

project

a guest
Jul 16th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.56 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<string.h>
  3. #include<conio.h>
  4. #include<stdlib.h>   //for using styme("CLS")
  5. #define ENTER 13
  6. //subfunction diclaration
  7. void login();
  8. void menu();
  9.  
  10. int main()
  11. {
  12.     login();       // call login function
  13.     return 0;
  14. }
  15. void login()
  16. {
  17.     int i;
  18.     char password[100],ch;
  19.     char username[100];
  20.     printf("\n\n\t\t*************************************************\n\t\t*\t\t\t\t\t\t*\n\t\t*\tENTER YOUR USERNAME AND PASSWORD\t*\n\t\t*\t\t\t\t\t\t*\n\t\t*************************************************\n");
  21.     printf("\n\t\t\tUSERNAME:");
  22.     scanf("%s",&username);
  23.     printf("\n\t\t\tPASSWORD:");
  24.  
  25.     for(i=0; i<100; i++)      //loop for password input
  26.  
  27.     {
  28.         ch = getch();       //getch don't showing input from user
  29.         if(ch==ENTER)
  30.         {
  31.            break;
  32.         }
  33.  
  34.         else {
  35.             password[i] = ch;
  36.         ch = '*' ;
  37.         printf("%c",ch);
  38.         }
  39.  
  40.     }
  41.  
  42.     password[i] = '\0';       //in string last character is a null character
  43.     if(strcmp(username,"abc")==0)   // strcmp for compearision
  44.     {
  45.  
  46.  
  47.         if(strcmp(password,"123")==0)
  48.         { getch();                   // getch is used to hold the window
  49.         system("CLS");
  50.             printf("\n\n\t\tSUCCESSFULLY LOG IN......");
  51.              printf("\n\n\t\tPress Any Key To Countinue..... ");
  52.              getch();
  53.         system("CLS");
  54.               menu();   // call menu function
  55.         }
  56.         else
  57.         {
  58.             printf("\n\n\t\tPlease Enter Correct Password.....");
  59.             printf("\n\n\t\tPress Any Key To Countinue..... ");
  60.             getch();
  61.         system("CLS"); //system("CLS") using for clear screen
  62.          login();    // call login function
  63.         }
  64.  
  65.  
  66.     }
  67.     else
  68.     {
  69.         printf("\n\n\t\tPlease Enter Correct Username.....");
  70.         printf("\n\n\t\tPress Any Key To Countinue..... ");
  71.         getch();
  72.         system("CLS");
  73.         login();  // call login function
  74.     }
  75.  
  76.  
  77.  
  78.  
  79. }
  80.  
  81. void menu()
  82. {
  83.     int choise,quite;
  84.     printf("\n\n\t\t   ======WELCOME TO BLOOD GROUP MANAGEMENT======\n");
  85.     printf("\n\n\t\t\t*********************************\n\t\t\t*\t\t\t\t*\n\t\t\t*\t     Main Menu      \t*\n\t\t\t*\t\t\t\t*\n\t\t\t*********************************\n\t\t\t*\t\t\t\t*");
  86.     printf("\n\t\t\t*\t  [1]Data Entry\t\t*\n");
  87.     printf("\t\t\t*\t  [2]Search\t\t*\n");
  88.     printf("\t\t\t*\t  [3]Delete\t\t*\n");
  89.     printf("\t\t\t*\t  [4]About\t\t*\n");
  90.     printf("\t\t\t*\t  [5]Exit\t\t*\n");
  91.     printf("\t\t\t*\t  [1]Data Entry\t\t*\n\t\t\t*\t\t\t\t*\n");
  92.     printf("\t\t\t*********************************\n\n");
  93.     printf("\t\t\t\tChoise Any Number: ");
  94.  
  95.     scanf("%d",&choise);
  96.     system("CLS");
  97.     switch(choise)
  98.     {
  99.     case 5:
  100.         printf("\n\n\n\t\t\t*********************************\n\t\t\t*\t   Are you sure?\t*\n\t\t\t*********************************\n\t\t\t*\t[1]YES   *\t[2]NO   *\n\t\t\t*********************************");
  101.         printf("\n\n\t\t\tChoise Any Number: ");
  102.         scanf("%d",&quite);
  103.         if(quite==1)
  104.         {
  105.         system("CLS");
  106.         printf("\n\n\n\n\n\n\t\t\t*********Thanks For Using*********\n\n\n\n\n\n\n\n\n\n\n");
  107.             break;
  108.         }
  109.         else if(quite==2)
  110.         {
  111.  
  112.         system("CLS");
  113.             menu();       // call menu function
  114.         }
  115.         else
  116.         {
  117.             printf("\n\n\t\t\tInvalid....\n\n ");
  118.             getch();
  119.             system("CLS");
  120.             menu();                     //if invalid go to menu
  121.  
  122.  
  123.         }
  124.  
  125.  
  126.  
  127.     }
  128. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement