value of TRUE???

Wade Guthrie evil at arcturus.UUCP
Thu Mar 9 06:26:42 AEST 1989


In article <987 at infmx.UUCP>, kevinf at infmx.UUCP (Kevin Franden) writes:
> Hi,  I hope someone out there in netland can decide a bet
> I have with a colleague.  

Strictly no sweatski -- what kinda bux are we talking about here?

> given: 	:The if() statement will evaluate to true provided that
> 	 the argument does not evaluate to 0.  (ie a=3; if (a)...)

So far, so good. . .
 
> Is then the value of true any nonzero integer?

Strictly speaking, yes. (see recent net flamewarz)

> What does if (a=3) evaluate to?

Well, a=3 is an expression (i.e., it evaluates to a value).  In the
event of 'a' being declared as an integer variable (I don't want to
get into the implications if it's not), then it is an *integer* 
expression.  Assigning a value to a variable causes the expression
to evaluate to the value being assigned to the variable -- so,
the expression a=3 evaluates to 3.  Hence:

	if(a=3)
	{
		/* this will always be executed */
		. . .
	}
	else
	{
		/* this will never be executed */
		. . .
	}


Wade Guthrie
evil at arcturus.UUCP
Rockwell International
Anaheim, CA

(Rockwell doesn't necessarily believe / stand by what I'm saying; how could
they when *I* don't even know what I'm talking about???)



More information about the Comp.lang.c mailing list