Quote:
Originally Posted by Flint
I'm interested to know why you think this is; as I cannot conceive of a logic where this makes sense. Aside from the fact that this isn't what happens. I'm just interested to hear your reasoning.
|
Say you call containDigit("abc")
Code:
int index = 0;
int length = strlen(password);
for (index = 0; index < length; index++ )
{
if (isdigit(password[index]))
return true;
}
It gets through these steps, and gets here:
Code:
cout << "Passwords must include at least on digit (1-9)" << endl;
cout << "Please enter a password: ";
cin.getline(password, SIZE);
The user enters "abc1".
And then:
The password is now "abc1", and containDigit() returned false.
You don't see the problem in your execution because your while loop corrects for the behavior of the test functions. But if you tested the functions individually, you would see it.
Quote:
Originally Posted by Flint
This code only "calls" passLength IF passLength is false.
What exactly do you mean by "IF passLength is false"? A function can only be false if it is called and executed.
Unlike the solutions graciously suggested by Pete Zicato and Happy Monkey, in my code I do not require a superfluous bool variable. I use the bool function to evaluate itself. Maybe this is "wrong" but it works.
|
My first suggestion also doesn't need the bool, without the side effects in the test functions.