Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- char user_name[20] = " ";
- char password[20] = " ";
- char users[][2][20] =
- { { "root", "98765" },
- { "moi", "allo" },
- { "abc", "motdepasse" },
- { "", "" }
- };
- int check_name()
- {
- int i;
- printf("Name: "); gets(user_name);
- printf("Pass: "); gets(password);
- for(i=0; users[i][0][0] != 0; i++)
- {
- if(strcmp(user_name, users[i][0]) == 0 &&
- strcmp(password, users[i][1]) == 0)
- return 1;
- }
- return 0;
- }
- void logon()
- {
- printf("Welcome to system...\n");
- exit(1);
- }
- void reject()
- {
- printf("Connection refused!\n");
- exit(0);
- }
- main()
- {
- unsigned int i;
- for(i=(unsigned)-3; i && !check_name(); i++);
- if(i>=(unsigned)-3)
- logon();
- else
- reject();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement