Path: utzoo!utgpu!jarvis.csri.toronto.edu!mailrus!ulowell!masscomp!ftw From: ftw@masscomp.UUCP (Farrell Woods) Newsgroups: comp.lang.c Subject: Re: value of TRUE??? Keywords: TRUE, if(), another nonzero value Message-ID: <819@masscomp.UUCP> Date: 7 Mar 89 20:11:14 GMT References: <987@infmx.UUCP> Reply-To: ftw@quasar.masscomp.UUCP (Farrell Woods) Distribution: usa Organization: Concurrent Computer Corporation - Westford, Ma Lines: 23 In article <987@infmx.UUCP> kevinf@infmx.UUCP (Kevin Franden) writes: >given: :The if() statement will evaluate to true provided that > the argument does not evaluate to 0. (ie a=3; if (a)...) Expressions have values in C. Since there is no boolean type in C, expressions that evaluate to non-zero values are taken as "true", and zero-valued as "false". >What does if (a=3) evaluate to? The expression "a = 3" has the value of 3, which is non-zero and therefore "true". Therefore: if (a = 3) printf("true!\n"); will always execute the printf(). -- Farrell T. Woods Voice: (508) 392-2471 Concurrent Computer Corporation Domain: ftw@masscomp.com 1 Technology Way uucp: {backbones}!masscomp!ftw Westford, MA 01886 OS/2: Half an operating system