Hello, I am struggling with Password verification. Can someone please help me.
Problem with this code: Just sets the characters between 6 and 15.
and it does not verifies uppercase, lowercase, numeric and alphabet which it must contain.
#include <iostream>
#include <cstring>
using namespace std;
bool testPassword(char *);
int verifyUpper(char *);
int verifyLower(char *);
int verifyNum(char *);
int verifyAlpha(char *);
}
//upper function
int verifyUpper(char *str)
{
int num = 0;
int length = strlen(str);
for (int count = 0; count < length; count++)
{
if (!isupper(str[count]))
num++;
}
return num;
}
//lower function
int verifyLower(char *str)
{
int num = 0;
int length = strlen(str);
for (int count = 0; count < length; count++)
{
if (!islower(str[count]))
num++;
}
return num;
}
//verify number contained
int verifyNum(char *str)
{ int num = 0;
int length = strlen(str);
for (int count = 0; count < length; count++)
{
if (!isdigit(str[count]))
num++;
}
return num;
}
int verifyAlpha(char *str)
{ int num = 0;
int length = strlen(str);
for (int count = 0; count < length; count++)
{
if (!isalpha(str[count]))
num++;
}
return num;
}
Thanks @JLBorges. Although I am not quite sure if my professor allows me to use 'cctype' because she has not gone through that type yet.
It's quite hard for me too, but i understood what you did there. Thank you again.