Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2016
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.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.     char username[20];
  10.     char password[10];
  11.     int cap = 0;
  12.     int num = 0;
  13.     int lower = 0;
  14.     int special = 0;
  15.  
  16.     printf("Hallo! Welcome to globzin.se \n");
  17.  
  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.     for (const char* c = password; *c != 0; ++c)
  25.     {
  26.         cap |= !!isupper(*c);
  27.         num |= !!isdigit(*c);
  28.         lower |= !!islower(*c);
  29.         special |= !!ispunct(*c);
  30.     }
  31.  
  32.     if (cap && num && lower && special)
  33.     {
  34.         system("cls");
  35.         printf("You made it! WHOOOOHO, cap: %d num: %d lower: %d special: %d \n\n", cap, num, lower, special);
  36.         printf("Welcome, %s \n", username);
  37.     }
  38.     else
  39.     {
  40.         printf("You have to type in a uppercase, a number, lowercase and a special character. \n");
  41.     }
  42.  
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement