Advertisement
Guest User

Untitled

a guest
Aug 6th, 2018
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.75 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",password);
  14. }
  15.  
  16. void check()
  17. {
  18. if (strcmp(username, "Admin") == 0)
  19. {
  20. if (strcmp(password, "Test") == 0)
  21. {
  22. printf("You have successfully logged in.");
  23. //write into file
  24. FILE *f = fopen("file.txt", "w");
  25. fprintf(f, "Username: %s\n", username);
  26. fprintf(f, "Password: %s\n", password);
  27. fclose(f);
  28. }
  29. else
  30. printf("Password or Username is incorrect")
  31. }
  32. else
  33. printf("Access denied");
  34. }
  35.  
  36. int main()
  37. {
  38. input();
  39. check();
  40.  
  41. return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement