Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!iuvax!bobmon From: bobmon@iuvax.cs.indiana.edu (RAMontante) Newsgroups: comp.lang.c Subject: Re: Awkward control structure Message-ID: <17914@iuvax.cs.indiana.edu> Date: 24 Feb 89 20:43:59 GMT Reply-To: bobmon@iuvax.cs.indiana.edu (RAMontante) Organization: malkaryotic Lines: 34 davidsen@crdos1.UUCP (bill davidsen) <13233@steinmetz.ge.com> : - [ ... ] - - Or, more simply with a goto: - UglyLabel: - if (!valid_pwd) { - ask for password - goto UglyLabel; - } - else { - validate password - } - - The object of this is not to ask the user to type a new password once -to set it, once to confirm you have it right, and then once again to -validate it. Twice is enough, particularly over a noisy phone line! (I'm not convinced that this goto example won't ask the new-user to validate the password once it's correctly entered. In any case...) Why do you want to avoid doubling the valid_pwd test? The code size shouldn't be a big factor, and the number of executions stays the same. I would think a natural control flow would be if (valid_pwd()) { validate_password(); } else do { get_new_password(); } while (!valid_pwd()); [I've made some things real C functions just for consistency with the control-structure syntax.]