Jul 24, 2016 at 3:52pm UTC
I am not even getting the error statement back. I am guessing that the issue is in main and not in the other functions. I am unsure of where. The if statement looks valid to me.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
cin.getline(passWord,20)
if (testPassWord(passWord))
{
cout << "Please wait - your password is being verified" << endl;
}
else
{
cout << "Invalid password. Please enter a password "
<< "with exactly 5 letters and 3 digits" << endl;
cout << "For example, my37RuN9 is valid" << endl;
}
bool testPassWord(char custPass[])
{
int numLetters, numDigits, length;
length = strlen(custPass);
numLetters = countLetters(custPass);
numDigits = countDigits(custPass);
if (numLetters == 5 && numDigits == 3 && length == 8)
{
return true ;
}
else
{
return false ;
}
}
Last edited on Jul 24, 2016 at 4:04pm UTC
Jul 24, 2016 at 4:08pm UTC
Your testPassWord function looks fine, as does the call to it.
I would suggest putting a cout of passWord just before you call testpassWord to see what you are passing. Or step through it using a debugger.
Jul 24, 2016 at 4:19pm UTC
It displays what is typed just fine.
I am not sure what you meant by step through it using the debugger?
Last edited on Jul 24, 2016 at 4:24pm UTC
Jul 24, 2016 at 5:55pm UTC
You could have a problem in your countLetters or countDigits functions. Since you did not provide those, it's hard to say.
I am not sure what you meant by step through it using the debugger?
http://www.cplusplus.com/forum/articles/28767/
Last edited on Jul 24, 2016 at 5:55pm UTC
Jul 24, 2016 at 6:39pm UTC
Silly me! Thanks Thomas1965.
And AbstractionAnon for the debugging tips.