Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int logIn(){
- char uName[100], uPass[100];
- int i, j;
- bool exists = false;
- while(true) {
- printf("Username: ");
- scanf("%s", uName);
- for (i = 0; i < 10; i++) {
- exists = false;
- if(strcmp(a[i].Username,uName) == 0){
- exists = true;
- j = i;
- break;
- }
- }
- if(exists = true){
- printf("Password: ");
- scanf("%s",uPass);
- if(strcmp(a[i].Password,uPass) == 0){
- printf("Success!");
- return j;
- }
- else{
- printf("Account doesn't exist or the password is wrong! Try again.");
- continue;
- }
- }
- }
- }
- void accCreate(){
- char username[100], password[100];
- int i;
- bool taken;
- int cCount,sCount,nCount = 0;
- //Username Creation
- while(true){
- printf("Enter a username: ");
- scanf("%s",username);
- for(i = 0;i < 10; i++) {
- taken = false;
- if (strcmp(a[i].Username,username) == 0) {
- taken = true;
- break;
- }
- }
- if(taken == true){
- printf("Username already taken! Please try a different one!\n");
- continue;
- }
- for(i = 0;i < 10; i++) {
- if (a[i].Username != 0){
- continue;
- }
- else{
- strcpy(a[i].Username,username);
- break;
- }
- }
- break;
- }
- //Password creation
- while(true) {
- int j;
- char tempPass[100];
- printf("Enter a password (Must contain at least one uppercase, number, and symbol): ");
- scanf("%s", password);
- printf("Confirm your password: ");
- scanf("%s", tempPass);
- //Pass check
- if (strcmp(password,tempPass) != 0) {
- printf("Passwords do not match!\n");
- continue;
- }
- if (strlen(password) < MIN) {
- printf("Password is too short! Must be at least 8 characters.\n");
- continue;
- }
- for (j = 0; password[j] != '\0'; j++) {
- if (password[j] >= 'a' && password[j] <= 'z')
- continue;
- else if (password[j] >= 'A' && password[j] <= 'Z') {
- cCount++;
- continue;
- } else if (password[j] >= '0' && password[j] <= '9') {
- nCount++;
- continue;
- } else {
- sCount++;
- continue;
- }
- }
- if (cCount >= 1 && nCount >= 1 && sCount >= 1) {
- break;
- } else {
- printf("Password does not meet the specified criteria.\n");
- continue;
- }
- }
- strcpy(a[i].Password,password);
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement