Advertisement
Guest User

Untitled

a guest
Aug 8th, 2018
133
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. #include<stdio.h>
  2. #include<stdlib.h>
  3.  
  4. char username[20];
  5. char password[10];
  6.  
  7. void input()
  8. {
  9. printf("Enter username: ");
  10. scanf("%s",username);
  11.  
  12. printf("Enter password: ");
  13. scanf("%s",password1);
  14.  
  15. printf("Please confirm password: ");
  16. scanf("%s",password2);
  17. }
  18.  
  19. void check()
  20. {
  21. if (strcmp(username, "Admin") == 0)
  22. {
  23. if (strcmp(password, "Test") == 0)
  24. {
  25. printf("You have successfully logged in.");
  26. //write into file
  27. FILE *f = fopen("file.txt", "w");
  28. fprintf(f, "Username: %s\n", username);
  29. fprintf(f, "Password: %s\n", password1);
  30. fclose(f);
  31. }
  32. else
  33. printf("Password or Username is incorrect")
  34. }
  35. else
  36. printf("Access denied");
  37. }
  38.  
  39. int main()
  40. {
  41. input();
  42. check();
  43.  
  44. return 0;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement