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

Re: Pointers
  By: Darin McBride to Rob Swindell on Thu Sep 11 2003 09:35 am

 >  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. 
 > it returned 2, your if would fail.

Okay, then:
        
        if((i=function(parm))!=FALSE)


 > Much better is:
 > 
 > i = function(parm);
 > if (i) /* ... */

Matter of style/preference.

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

I was simply answering a question about how to do an assignment/test in one
expression and avoid warnings.

                                                  digital man

Snapple "Real Fact" #132:
A crocodile cannot move its tongue. 
--- SBBSecho 2.00-Win32
* Origin: Vertrauen - vert.synchro.net (1:103/705)
SEEN-BY: 633/267 270
@PATH: 103/705 218/903 10/3 106/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™.