TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: All
from: Kurt Kuzba
date: 2003-09-06 02:06:46
subject: Pointers

From: kkuzba{at}centurytel.net
To: c_echo{at}yahoogroups.com

* Author: Bo Simonsen
BS> JB>  char *ptr = test();
BS> JB>  if( !ptr )
BS> JB>  seems shorter to me
BS>  Indeed, but how is it in C, with integers, i've defined TRUE
BS>  as 1 and FALSE as 0, is
BS>     if(function(parm) == TRUE)
BS>  nessersary or could I use if(function(parm)) ?

    By default, 0 is equal to untrue.  If you test a value, such as
 a pointer, the conditional will be true for any nonzero value.

    if(myPointer) free(myPointer);

 This will only call free when myPointer has a nonzero value.  To
 be consistent and take advantage of this, you should define TRUE
 as 1 and FALSE as 0.  If all of your conditionals will test for
 TRUE or FALSE explicitly, then it doesn't matter, really, except
 that it is counter-intuitive for the C environment.

>  kkuzba{at}centurytel.net   http://home.centurytel.net/kkuzba
>  'Put away that bow, Master Elf!'

--- SoupGate-Win32 v1.05
* Origin: kkuzba{at}centurytel.net (2:292/516.666)
SEEN-BY: 633/267 270
@PATH: 292/516 854 140/1 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™.