farkhan

Untitled

Dec 6th, 2019
218
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.71 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 && strcmp(logPass,pass[i])==0){
  51.             printf("\nLogin Succesfuly\n");
  52.             printf("Change Password [Y/N] ? ");
  53.             scanf("%c",&change);
  54.             if(change == 'y' || change == 'Y'){
  55.                 update(i);
  56.             }else{
  57.                 list();
  58.             }
  59.         }else{
  60.             printf("\nLogin Failed\n");
  61.             list();
  62.         }
  63.     }      
  64. }
  65.  
  66. void list(){
  67.     printf("\n1. REGISTER \n2. LOGIN \n3. EXIT PROGRAM");
  68.     printf("\nChoose: ");
  69.     scanf("%d",&choose);
  70.     if(choose==1){
  71.         regis();
  72.     }else if(choose==2){
  73.         login();
  74.     }else{
  75.         printf("\n~~~Thank You~~~\n");
  76.         exit(1);
  77.     }
  78. }
  79.  
  80. void update(int x){
  81.     fflush(stdin);
  82.     printf("Enter The New Password: ");
  83.     gets(New);
  84.     strcpy(pass[x], New);
  85.     printf("Password Has Benn Changed\n");
  86.     list();
  87. }
Advertisement
Add Comment
Please, Sign In to add comment