Good password or not Program

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++;

else if(password[i]>=65&&password[i]<=90)
atleastoneLowercaseletter++;
else if(password[i]>=16&&password[i]<=25)
atleastoneDigit++;
else
atleastonealphanumericCharecter++;

}

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;
}
Sorry, but what language is this supposed to be?
Are you saying this sarcastically? im comparing charecters of the array to the ASCII values. Cant I do that?
void main()
No I'm serious. What language is this?

Oh, and the uppercase letters don't go from 33 to 58.
i referred to a table online. I think it may be wrong. If I do not use the ASCII values what do you recommend me to use?
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)
Thank you! You made it easier for me! i was only thinking about ASCII values and forgot all about functions!
void main()

is the old main function for the old C++ of 1998. The old Turbo C++ 3 compiler accepts it.
It's never been correct C++; C++ 1998 was just the first formal ISO definition. Before that, we just had Bjarne's word for it :)
closed account (S6k9GNh0)
There are a lot of modern C++ compilers that accept void main() but that doesn't mean it's right.
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()?
Last edited on
closed account (S6k9GNh0)
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.
Last edited on
gcc does reject by default. http://ideone.com/Qo8y1

Your link compiles it as C code. It is acceptable C code. If you tried to compile it as C++, it would be rejected.
Last edited on
Topic archived. No new replies allowed.