View Single Post
  #2   Spotlight this post!  
Unread 14-02-2004, 20:00
kiracofe8 kiracofe8 is offline
Registered User
#1317 (Digital Fusion)
Team Role: Engineer
 
Join Date: Nov 2001
Location: Columbus, OH
Posts: 30
kiracofe8 will become famous soon enough
Re: Boolean statement

Quote:
Originally Posted by blindguyinanorg
simple question, in an if statement is a value of 0 = to false or to i need to say !variable==0 to get false( or variable==1). not too important it will just save me time in writing the code and i dont want to go back and have to fix it.
int x = 0;
if (x)
//this code never executes
else
//this code always excutes


However, in C, I would consider it to be good coding practice to explicitly write the test as:

if (x == 0)
// stuff
else
// other stuff

or even

if (x != 0)
//other stuff
else
//stuff.
__________________
/* Daniel */