Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2016
178
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.97 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <ctype.h>
  4. #include <math.h>
  5. #include <string.h>
  6.  
  7. int main()
  8. {
  9.     // Variable declaration.
  10.     char username[20];
  11.     char password[10];
  12.     int cap = 0, num = 0, lower = 0, special = 0, passwordCorrect = 0;
  13.  
  14.     //MOTD
  15.     printf("Hallo! Welcome to globzin.se \n");
  16.  
  17.     //Login Session
  18.     printf("\nThe password must contain a number, uppercase letter and a special character");
  19.     printf("\nEnter your username: ");
  20.     scanf(" %s", username);
  21.     printf("\nEnter your password: ");
  22.     scanf(" %s", password);
  23.  
  24.     // A loop that runs through all the chars one by one.
  25.     int i;
  26.     for (i = 0; i <= 20; i++)
  27.     {
  28.         if (isupper(password[i]))
  29.         {
  30.             cap = 1;
  31.             printf("\nUpper! YEY %d \n", cap);
  32.             continue;
  33.         }
  34.         if (isdigit(password[i]))
  35.         {
  36.             num = 1;
  37.             // To print the num variable out. For the check.
  38.             printf("\nDigit! YEY %d \n", num);
  39.             continue;
  40.         }
  41.         if (islower(password[i]))
  42.         {
  43.             lower = 1;
  44.             // To print the lower variable out. For the check.
  45.             printf("\nLower! YEY %d \n", lower);
  46.             continue;
  47.         }
  48.         if (ispunct(password[i]))
  49.         {
  50.             special = 1;
  51.             // To print the special variable out. For the check.
  52.             printf("\nSpecial! YEY %d \n", special);
  53.             continue;
  54.         }
  55.         else {
  56.             break;
  57.         }
  58.     }
  59.     // The score from the password checks.
  60.     passwordCorrect = cap + num + lower + special;
  61.     if (passwordCorrect >= 4)
  62.     {
  63.         system("cls");
  64.         printf("You made it! WHOOOOHO, cap: %d num: %d lower: %d special: %d \n\n", cap, num, lower, special);
  65.         printf("Welcome, %s \n", username);
  66.     }
  67.     else {
  68.         printf("You have to type in a uppercase, a number, lowercase and a special character. \n");
  69.     }
  70.  
  71.     return 0;
  72. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement