Advertisement
DrAungWinHtut

basic_login.c

Nov 9th, 2022
881
1
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.88 KB | None | 1 0
  1. #include<stdio.h>
  2. #include<string.h>
  3. #include<conio.h>
  4.  
  5. int main()
  6. {
  7.     char uName[20] = { '\0' };
  8.     char passWord[20] = { '\0' };
  9.     printf("please enter your name : ");
  10.     gets_s(uName); //gcc gets() stdio.h
  11.     printf("please enter your password :  ");
  12.     //gets_s(passWord); //gcc gets() stdio.h
  13.     //Enter မခေါက်မချင်း စာလုံးတစ်လုံးချင်းဖတ်ပြီး passWord array ထဲ ထည့်မယ်။
  14.     //အဆုံးမှာ '\0' ထည့်ပေးလိုက်မယ်
  15.     char ch = '\0';
  16.     int i = 0;
  17.     while (   (ch = _getch())   != '\r')
  18.     {
  19.         printf("*");
  20.         passWord[i] = ch;
  21.         i++;
  22.     }
  23.     printf("\n");
  24.    
  25.  
  26.    
  27.     if (    (strcmp(uName, "aung") == 0 ) && (strcmp(passWord, "1234") == 0)  )
  28.     {
  29.         puts("user name and password are OK!");
  30.     }
  31.     else {
  32.         puts("user name and password are NOT OK!");
  33.     }
  34.    
  35.     return 0;
  36. }
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement