diff --git a/src/createEmployeeAccount.c b/src/createEmployeeAccount.c index 37b8452..f2dcd1a 100644 --- a/src/createEmployeeAccount.c +++ b/src/createEmployeeAccount.c @@ -16,11 +16,11 @@ int StringLengthCounter(char* string) return characterCounter; } -bool isValidPassword(char* employeePassword, int minimumStringLength) +bool isValidPassword( char *password, int minimumLength) { - char* stringpointer = employeePassword; - int employeePasswordLength = 0; - bool letterFound = false, punctuationFound = false, numberFound = false; + /*created a pointer(*stringpointer) which helps loop through characters of the string password*/ + char *stringpointer = password; + bool letterFound = false, symbolFound = false, numberFound = false; while(*stringpointer!='\0') { @@ -34,14 +34,13 @@ bool isValidPassword(char* employeePassword, int minimumStringLength) } else if(ispunct(* stringpointer)) { - punctuationFound = true; + symbolFound = true; } - if( employeePasswordLength >= minimumStringLength && letterFound && numberFound && punctuationFound) + if( strlen(password) >= minimumLength && letterFound && numberFound && symbolFound) { return true; } ++stringpointer; - ++employeePasswordLength; } return false; @@ -112,7 +111,7 @@ void getNewEmployeeCredentials() else if(isValidEmployeeID(employeeId,employeeIdLength) && !isValidPassword(employeePassword,minimumPasswordLength)) { - printf("Error : the entered password should be at least 5 characters long and should contain at least 1 digit, 1 alphabet and 1 punctuation character!"); + printf("Error : the entered password should be at least 5 characters long and should contain at least 1 digit, 1 alphabet and 1 symbol!"); } else diff --git a/src/createEmployeeAccount.h b/src/createEmployeeAccount.h index 7940693..12b38f2 100644 --- a/src/createEmployeeAccount.h +++ b/src/createEmployeeAccount.h @@ -8,7 +8,7 @@ #include bool isValidEmployeeID(const char* employee, int maximumLength); -bool isValidPassword(char* employeePassword, int minimumStringLength); +bool isValidPassword( char* password, int minimumLength); bool createNewEmployee(char* employeeId, char* employeePassword); int StringLengthCounter(char* string);