A password is good if it has at least one digit,one alphanumeric charecter, one uppercase letter, one ordinary lowercase letter letter and consists of 8 charecters or more. I created this program, but I'm not getting correct results.. What is the problem?
void main()
{
cout<<"This program checks whether the password entered by the user is good or not"<<endl;
cout<<"Enter the password"<<endl;
char password[100];
int atleastoneDigit=0,atleastoneLowercaseletter=0,atleastoneUppercaseletter=0,atleastonealphanumericCharecter=0;
cin>>password;
int length=strlen(password);
for(int i=0;i<length;i++)
{
if(password[i]>=33&&password[i]<=58)//ASCII values refering to uppercase letters
atleastoneUppercaseletter++;
if(length>=8&&atleastoneDigit!=0&&atleastoneUppercaseletter!=0&&atleastoneLowercaseletter!=0&&atleastonealphanumericCharecter!=0)
cout<<"This is a good password!"<<endl;
else
cout<<"This is not a good password!"<<endl;
}
1. You should always use int main(int, char **).
2. You can use isalpha, isdigit, isgraph, isprint (Is a A-Z/a-z, is 0-9, is a symbol, can be represented)
GCC and the LLVM (via Clang++ interface) reject it as an error; the MS C++ compiler does accept it, I'm told. What other modern C++ compilers accept void main()?
gcc does not reject by default (http://ideone.com/DvmG3). Older versions of VC++ accepted it. clang++ is (relatively) new and has no reason to follow backwards compatibility but I'm sure you can find a way to disable the error given the nature of the beast.