TIP: Click on subject to list as thread! ANSI
echo: c_echo
to: Bo Simonsen
from: Jasen Betts
date: 2003-09-06 07:49:30
subject: Pointers

Hi Bo.

05-Sep-03 14:22:32, Bo Simonsen wrote to Jasen Betts


 BS> Indeed, but how is it in C, with integers, i've defined TRUE as 1
 BS> and FALSE as 0, i

 BS> if(function(parm) == TRUE)

 BS> nessersary or could I use if(function(parm)) ?

if  (also while, until, for, etc...)  treats anything other than 0 (or NULL
which is usually defined as 0 or
(void*)0) as true.

so things like -1 (and even strings) are treated as true

assuming function(parm) returns 2 ....

if(function(parm) == TRUE) puts("2 is not 1: this won't happen");

if(function(parm)) puts("2 is not false: this will happen");

if("pigs fly") puts("All non-null pointers are true");

 -=> Bye <=-

---
* Origin: Darth Vader sleeps with a Teddywookie. (3:640/1042)
SEEN-BY: 633/267 270
@PATH: 640/1042 531 954 774/605 123/500 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™.