View Single Post
Old 11-22-2010, 02:47 PM   #8
Happy Monkey
I think this line's mostly filler.
 
Join Date: Jan 2003
Location: DC
Posts: 13,575
I think yours would return a valid password, but [edit]it won't tell them what's wrong if they enter a short password twice in a row it's not as concise as it could be.

Code:
bool passLength(string) // just print error, and return true/false.  Don't read a new pw
bool containDigit(string) // just print error, and return true/false.  Don't read a new pw

string getPW()
{
  string pw = read line;
  while (( ! passlength(pw) ) || ( ! containDigit(pw) ))
  {
    pw = read line;
  }
  return pw;
}
__________________
_________________
|...............| We live in the nick of times.
| Len 17, Wid 3 |
|_______________| [pics]

Last edited by Happy Monkey; 11-22-2010 at 02:55 PM. Reason: logic error
Happy Monkey is offline   Reply With Quote