Description
The purpose of this challenge is to manually manipulate character arrays. This challenge validates a string against password validity rules.
Requirements
- Make sure you follow all the steps in order. As you read the instructions below, glance at the sample main() function to get a better understanding of the requirement.
- Declare three variables in main: min_uppers, min_lowers, min_length
- Write a function int get_int(char prompt[], int min, int max). This function will prompt the user to enter a number that must be between min and max, inclusively. Use this function in main:
- to ask the user how many upper case numbers are required. Allow the user to enter at least 1 but not more than 3
- to ask the user how many lower case numbers are required. Allow the user to enter at least 1 but not more than 3
- to ask the user for the minimum length of the password. Allow the user to enter at least 6 but not more than 8
- In the get_int() function, make sure to specify the prompt parameter as a c-string. This parameter represents the text displayed to the user in the function. It is okay to use cout/cin in this function since that is its job.
- Write a function int validate_password(char pwd[], int min_uppers, int min_lowers, int min_length). This function will return different integer values to indicate why the validation failed. For example, you could:
- return a 1 to indicate that the password is too short
- return a 2 to indicate that the password is too long. Enforce a maximum length of 12 characters.
- return a 3 to indicate that the password does not have enough upper case characters
- …and so on
- return a 0 (zero) to indicate that the password passed in satisfies all the validation requirements.
- Then, ask the user to enter sample passwords and use the validate_password() function to validate it against the requirements specified by the user (See sample interaction)
Sample main()
Sample Interaction / Output
LEGEND
PROGRAM OUTPUT
USER INPUT
FROM INPUT
CATALOG ID: CPP-CHAL0014
Print Requirements