Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: utzoo!mnetor!uunet!seismo!mcnc!unc!steele
From: steele@unc.cs.unc.edu (Oliver Steele)
Newsgroups: comp.lang.c
Subject: Re: Defining TRUE and FALSE
Message-ID: <832@unc.cs.unc.edu>
Date: Sun, 19-Jul-87 14:16:42 EDT
Article-I.D.: unc.832
Posted: Sun Jul 19 14:16:42 1987
Date-Received: Wed, 22-Jul-87 00:42:21 EDT
References: <13851@watmath.UUCP> <632@itsgw.RPI.EDU> <13259@topaz.rutgers.edu> <6123@brl-smoke.ARPA> <208@vianet.UUCP>
Reply-To: steele@unc.UUCP (Oliver Steele)
Organization: University of North Carolina, Chapel Hill
Lines: 24
Keywords: boolean, true, false

In article <208@vianet.UUCP> devine@vianet.UUCP (Bob Devine) writes:
>  I've used this method [writing "flag++" to set the boolean "flag" to
>true] many times -- but with a purpose in mind.  Doing it with a test
>allows a easy check for multiple use of a option.  For example, W_flag
>is set to 0 at the start and the following code is inside of a getopt()
>loop.
>
>    if (W_flag++)
>    {
>	 /* AI == Artificial Intimidation */
>         printf("Don't type the W flag twice again.  Or else...\n");
>	 exit(rand());
>    }

It's often more useful to have each use be a toggle (W_flag = !W_flag).
The default value of the flag can then be reversed by use of an alias or
an environment variable without locking the user into that default
choice.

------------------------------------------------------------------------------
Oliver Steele				  ...!{decvax,ihnp4}!mcnc!unc!steele
							steele%unc@mcnc.org

	"They're directly beneath us, Moriarty.  Release the piano!"