TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: Rob Swindell
from: Darin McBride
date: 2003-09-11 08:35:02
subject: Pointers

Hello Rob!

Replying to a message of Rob Swindell to Bo Simonsen:

 RS>   Re: Pointers
 RS>   By: Bo Simonsen to Jasen Betts on Fri Sep 05 2003 03:22 pm

 >> Indeed, but how is it in C, with integers, i've defined TRUE as 1 and
 >> FALSE  0, is          if(function(parm) == TRUE)  nessersary or could
 >> I use if(function(parm)) ?

 RS> There's no assignment in that expresion, so it's fine (without the ==
 RS> TRUE).

 RS> But if you did:

 RS>            if(i=function(parm))

 RS> Some compilers will generate a warning, so it's often better to use:

 RS>            if((i=functin(parm))==TRUE)  /* no warning */

No, I don't think so.  function() may return any non-zero value to be true.
 If it returned 2, your if would fail.

Much better is:

i = function(parm);
if (i) /* ... */

I don't see what the fascination is with cramming everything into a single
statement.  C just isn't built properly for that.

Perl, however, ... ;-)

Darin

---
* Origin: Tanktalus' Tower BBS (1:250/102)
SEEN-BY: 633/267 270
@PATH: 250/102 99 10/345 106/1 2000 633/267

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.