Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- char* registeredClientDatabase[50][12];
- char* pendingClientDatabase[50];
- char empty[50] = "null";
- void adminLogin();
- void clientRegister();
- char passwordConversion(char username[50]);
- int main(int argc, char *argv[]){
- char selection[50];
- char action[50];
- int i, j;
- for(i = 0; i < 50; i++)
- {
- for(j = 0; j < 12; j++)
- {
- registeredClientDatabase[i][j] = empty;
- }
- }
- for(i = 0; i < 50; i++)
- {
- for(j = 0; j < 2; j++)
- {
- pendingClientDatabase[i][j] = empty;
- }
- }
- do
- {
- printf("Welcome to the Home Screen");
- do
- {
- printf("What would you like to log in as?\n");
- printf("Please type 'Admin' to log in as an admin: \n");
- printf("Please type 'Client' to log in as a client: \n");
- scanf(" %s", &selection);
- }
- while((strcmp(selection, "Admin") != 0) || (strcmp(selection, "Client") != 0));
- if(strcmp(selection, "Admin") == 0)
- {
- printf("Welcome to the admins' login screen: \n");
- adminLogin();
- do
- {
- }
- while(strcmp(action, "Exit") != 0);
- }
- else
- {
- printf("Welcome to the clients' login screen: \n");
- char clientAction[50];
- do
- {
- printf("Would you like to Login or Register? \n");
- printf("Please type 'Login' to login: \n");
- printf("Please type 'Register' to register: \n");
- scanf(" %s", &clientAction);
- }
- while((strcmp(clientAction, "Login") != 0) || (strcmp(clientAction, "Register") != 0));
- if(strcmp(clientAction, "Register") == 0)
- {
- clientRegister();
- }
- else
- {
- int loginFlag = 0;
- char registerUsername[50];
- printf("Please type in your username: \n");
- scanf(" %s", ®isterUsername);
- for(i = 0; i < 50; i++)
- {
- if(strcmp(registerUsername, registeredClientDatabase[i][1]) == 0)
- {
- loginFlag = 1;
- registeredClientDatabase[i][2] = passwordConversion(registerUsername);
- }
- }
- if(loginFlag = 1)
- {
- }
- else
- {
- printf("We're sorry but the username that you have provided does not exist in our database of registered clients \n");
- }
- }
- }
- }
- while(strcmp(action, "Skata") != 0);
- return 0;
- }
- void adminLogin()
- {
- char username[50];
- char password[50];
- do
- {
- printf("Please provide the admin's username: \n");
- scanf(" %s", &username);
- }
- while(strcmp(username, "admin") != 0);
- do
- {
- printf("Please provide the admin's password: \n");
- scanf(" %s", &password);
- }
- while(strcmp(password, "pizza") != 0);
- }
- void clientRegister()
- {
- char username[50];
- int flag;
- int i;
- do
- {
- flag = 1;
- printf("Please choose your username: \n");
- scanf(" %s", &username);
- for(i = 0; i < 50; i++)
- {
- if((strcmp(username, pendingClientDatabase[i]) == 0) || (strcmp(username, registeredClientDatabase[i][1]) == 0))
- {
- flag = 0;
- }
- }
- }
- while(flag == 0);
- for(i = 0; i < 50; i++)
- {
- if((flag == 1) && (strcmp(pendingClientDatabase[i], empty) == 0))
- {
- pendingClientDatabase[i] = username;
- flag = 0;
- }
- }
- }
- char passwordConversion(char username[50])
- {
- char lowerCaseLetters[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
- char CapsLetters[26] = {'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z'};
- char password[50];
- int i = 0, j =0;
- int letterCheck = 3;
- while(username[i] != '\0')
- {
- for(j = 0; j < 26; j++)
- {
- if(username[i] == lowerCaseLetters[j])
- {
- if(letterCheck % 2 == 1)
- {
- password[i] = CapsLetters[j];
- }
- else
- {
- password[i] = lowerCaseLetters[j];
- }
- letterCheck = letterCheck + 1;
- }
- }
- }
- return password;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement