Advertisement
farkhan

Untitled

Dec 6th, 2019
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.92 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3. #include <stdlib.h>
  4.  
  5. char user[5][25],pass[5][25],again;
  6. char logUser[25],logPass[25],New[25],change;
  7. int data=0,choose,i;
  8.  
  9. void regis();
  10. void login();
  11. void list();
  12. void update(int x);
  13.  
  14. int main(){
  15.     printf("~~~WELCOME~~~");
  16.     list();
  17.     return 0;
  18. }
  19.  
  20. void regis(){
  21.     if(data==5){
  22.         printf("\nAccount Has Been Full\n");
  23.         login();
  24.     }else{
  25.     printf("Registration\n");
  26.     fflush(stdin);
  27.     printf("Enter The Username: ");
  28.     gets(user[data]);
  29.     printf("Enter The Password: ");
  30.     gets(pass[data]);
  31.     data++;
  32.     printf("\nRegister Again? [Y]/[N]: ");
  33.     scanf("%c",&again);
  34.     if(again=='Y'||again=='y'){
  35.         regis();
  36.     }else{
  37.         list();
  38.     }
  39.     }
  40. }
  41.  
  42. void login(){      
  43.     printf("\nLogin: \n");
  44.     fflush(stdin);
  45.     printf("Enter The Username: ");
  46.     gets(logUser);
  47.     printf("Enter The Password: ");
  48.     gets(logPass);
  49.     for(i = 0;i < data; i++){  
  50.         if(strcmp(logUser,user[i])==0){
  51.             if(strcmp(logPass,pass[i])==0){
  52.                 printf("\nLogin Succesfuly\n");
  53.                 printf("Change Password [Y/N] ? ");
  54.                 scanf("%c",&change);
  55.                 if(change == 'y' || change == 'Y'){
  56.                     update(i);
  57.                     break;
  58.                 }else{
  59.                     list();
  60.                     break;
  61.                 }
  62.             break;    
  63.             }else{
  64.                 printf("Login Failed\n");
  65.                 list();
  66.                 break;
  67.             }
  68.         }else{
  69.             continue;
  70.         }
  71.     }      
  72. }
  73.  
  74. void list(){
  75.     printf("\n1. REGISTER \n2. LOGIN \n3. EXIT PROGRAM");
  76.     printf("\nChoose: ");
  77.     scanf("%d",&choose);
  78.     if(choose==1){
  79.         regis();
  80.     }else if(choose==2){
  81.         login();
  82.     }else{
  83.         printf("\n~~~Thank You~~~\n");
  84.         exit(1);
  85.     }
  86. }
  87.  
  88. void update(int x){
  89.     fflush(stdin);
  90.     printf("Enter The New Password: ");
  91.     gets(New);
  92.     strcpy(pass[x], New);
  93.     printf("Password Has Benn Changed\n");
  94.     list();
  95. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement