Advertisement
Guest User

Untitled

a guest
Apr 19th, 2019
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.56 KB | None | 0 0
  1. #include <stdio.h>
  2. int main(){
  3. char name[50]="Alex";
  4. char password[50]="password";
  5. int a, b;
  6. char ai_cont[5];
  7. int triesLeft=3;
  8. int triesLeftpassword=3;
  9. fflush(stdout);
  10.  
  11. //ai cont sau nu ai cont?
  12. printf("Ai cont? Da/Nu -> ");
  13. fflush(stdout);
  14. scanf("%s", ai_cont);
  15.  
  16. if(strcmp(ai_cont,"da") && strcmp(ai_cont,"Da") == 0){
  17. printf("Log in: \n");
  18.  
  19. //sectiune de login - username
  20. do{
  21. printf("username: ");
  22. fflush(stdout);
  23. scanf("%s",name);
  24. a = strcmp(name,"Alex");
  25. if(a!=0)
  26. {
  27. triesLeft--;
  28. printf("You are not Alex! You have %d tries left!\n", triesLeft);
  29. }
  30. if(triesLeft == 0){
  31. printf("You are not Alex!! Go away!!");
  32. }
  33. }while(a != 0 && triesLeft != 0);
  34.  
  35. //sectiune de login - password
  36. if(strcmp(name,"Alex") == 0){
  37. do{
  38. printf("password: ");
  39. fflush(stdout);
  40. scanf("%s",password);
  41. b = strcmp(password,"password");
  42. if(b!=0)
  43. {
  44. triesLeftpassword--;
  45. printf("You are not Alex! You have %d tries left!\n", triesLeftpassword);
  46. }
  47. if(triesLeftpassword == 0){
  48. printf("Wrong password! Acces denied!");
  49. }
  50. }while(b != 0 && triesLeftpassword != 0);
  51. }
  52.  
  53. //daca loginul este complet
  54. if(strcmp(name,"Alex") == 0 && strcmp(password,"password") == 0){
  55. printf("You enter in your account, Alex!\n\n");
  56. }
  57. else{
  58. return 1;
  59. }
  60.  
  61. //meniul cu optiuni
  62. printf("1- Media;\n");
  63. printf("2- Note;\n");
  64. printf("3- Restante;\n");
  65. printf("4- Credite;\n");
  66. printf("5- Date personale.");
  67. }
  68.  
  69. return 0;
  70. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement