Advertisement
Guest User

Untitled

a guest
Aug 10th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.91 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <string.h>
  3.  
  4. int authenticateUser();
  5. void userMenu();
  6. void adminMenu();
  7.  
  8. int main() {
  9. int id = authenticateUser();
  10.  
  11. if(id > -1) {
  12. if(id == 0) {
  13. adminMenu();
  14. } else {
  15. userMenu();
  16. }
  17.  
  18. return 0;
  19. } else {
  20. printf("Authentication Failed\n");
  21. return 1;
  22. }
  23. }
  24.  
  25. int authenticateUser() {
  26. char username[16];
  27. char password[16];
  28.  
  29. printf("Username: ");
  30. scanf("%s", username);
  31.  
  32. printf("Password: ");
  33. scanf("%s", password);
  34.  
  35. if(strcmp(username, "user1") == 0 && strcmp(password, "password") == 0) {
  36. return 1;
  37. } else if(strcmp(username, "admin") == 0 && strcmp(password, "@dm1n") == 0) {
  38. return 0;
  39. }
  40.  
  41. return -1;
  42. }
  43.  
  44. void userMenu() {
  45. printf("Opening the user menu...\n");
  46. }
  47.  
  48. void adminMenu() {
  49. printf("Opening the admin menu...This is a super secret message!!!1!\n");
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement