Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- //Hisham Salah
- int userAndpassChecker(char U[], char P[]) {
- char usern[20] = "admin123";
- char passw[20] = "admin123admin";
- int c = 0;
- for (int j = 0; U[j]!='$' ;j++) {
- if (U[j] != usern[j])
- return 0;
- else
- c++;
- }
- if (c != 8)
- return 0;
- else
- c = 0;
- for (int h = 0; P[h]!='$';h++) {
- if (P[h] != passw[h])
- return 0;
- else
- c++;
- }
- if (c != 13)
- return 0;
- return 1;
- }
- int main() {
- char user[100] = { 0 };
- char pass[100] = { 0 };
- printf("\n\nTo access the administrator page , please enter your username and passowrd\n\n");
- printf("\nEnter the username..... For Example Name$ (It should end with $)\n");
- for (int i = 0; user[i - 1] != '$';i++)
- scanf_s("%c", &user[i]);
- printf("\nEnter the password..... For Example Pass123$ (It should end with $)\n");
- for (int j = 0; pass[j - 1] != '$';j++)
- scanf_s("%c", &pass[j]);
- while (userAndpassChecker(user, pass) != 1){
- printf("\nWrong username or passowrd ... Please re-enter username and password\n");
- printf("\nPlease enter the username:");
- for (int i = 0; user[i - 1] != '$';i++)
- scanf_s("%c", &user[i]);
- printf("\nPlease enter the password:");
- for (int j = 0; pass[j - 1] != '$';j++)
- scanf_s("%c", &pass[j]);
- }
- printf("\nYou have access to the administrator page\n");
- system("pause");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement