Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <ctype.h>
- #include <math.h>
- #include <string.h>
- int main()
- {
- // Variable declaration.
- char username[20];
- char password[10];
- int cap = 0, num = 0, lower = 0, special = 0, passwordCorrect = 0;
- //MOTD
- printf("Hallo! Welcome to globzin.se \n");
- //Login Session
- printf("\nThe password must contain a number, uppercase letter and a special character");
- printf("\nEnter your username: ");
- scanf(" %s", username);
- printf("\nEnter your password: ");
- scanf(" %s", password);
- // A loop that runs through all the chars one by one.
- int i;
- for (i = 0; i <= 20; i++)
- {
- if (isupper(password[i]))
- {
- cap = 1;
- printf("\nUpper! YEY %d \n", cap);
- continue;
- }
- if (isdigit(password[i]))
- {
- num = 1;
- // To print the num variable out. For the check.
- printf("\nDigit! YEY %d \n", num);
- continue;
- }
- if (islower(password[i]))
- {
- lower = 1;
- // To print the lower variable out. For the check.
- printf("\nLower! YEY %d \n", lower);
- continue;
- }
- if (ispunct(password[i]))
- {
- special = 1;
- // To print the special variable out. For the check.
- printf("\nSpecial! YEY %d \n", special);
- continue;
- }
- else {
- break;
- }
- }
- // The score from the password checks.
- passwordCorrect = cap + num + lower + special;
- if (passwordCorrect >= 4)
- {
- system("cls");
- printf("You made it! WHOOOOHO, cap: %d num: %d lower: %d special: %d \n\n", cap, num, lower, special);
- printf("Welcome, %s \n", username);
- }
- else {
- printf("You have to type in a uppercase, a number, lowercase and a special character. \n");
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement