Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include<stdio.h>
- #include<stdlib.h>
- char username[20];
- char password[10];
- void input()
- {
- printf("Enter username: ");
- scanf("%s",username);
- printf("Enter password: ");
- scanf("%s",password);
- }
- void check()
- {
- if (strcmp(username, "Admin") == 0)
- {
- if (strcmp(password, "Test") == 0)
- {
- printf("You have successfully logged in.");
- //write into file
- FILE *f = fopen("file.txt", "w");
- fprintf(f, "Username: %s\n", username);
- fprintf(f, "Password: %s\n", password);
- fclose(f);
- }
- else
- printf("Password or Username is incorrect")
- }
- else
- printf("Access denied");
- }
- int main()
- {
- input();
- check();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement