Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <ctype.h>
- #include <string.h>
- //password challenge
- int main()
- {
- char myPassword[50];
- //grab password
- //todo Why the fuck teach people to get BOFd by default?
- printf("Please input your password!\n");
- fgets(myPassword, 50, stdin);
- // printf("pass: %s\n", myPassword);
- //check size
- size_t arrayLength = strlen(myPassword);
- // printf("length: %ld\n", arrayLength);
- //requirements
- int upper = 0;
- int lower = 0;
- int cashSymbol = 0;
- for(int i = 0; i < arrayLength; i++){
- //printf("char: %c\n", myPassword[i]);
- if (upper == 0 || lower == 0 || cashSymbol == 0){
- if ( isupper(myPassword[i]) ){
- upper += 1;
- // printf("Found upper!");
- }
- else if ( myPassword[i] == '$' ) {
- cashSymbol += 1;
- // printf("Found $ symbol!");
- }
- else if ( islower(myPassword[i])){
- lower += 1;
- // printf("Found lower!");
- }
- } else {
- printf("Upper, lower, and special symbol located. Great password.\n");
- return 0;
- }
- }
- if (upper == 0 || lower == 0 || cashSymbol == 0){
- printf("Did not find an upper, lower, and cash symbol in the password.\n");
- return 1;
- }
- printf("Upper, lower, and special symbol located. Great password.\n");
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement