Go to Post This is an Internet forum- if you want to relax, sit next to a pool and sun bathe. However, the rest of us will have a mature discussions and debates on the CD forums. - MikeDubreuil [more]
Home
Go Back   Chief Delphi > Technical > Programming
CD-Media   CD-Spy  
portal register members calendar search Today's Posts Mark Forums Read FAQ rules

 
 
 
Thread Tools Rate Thread Display Modes
Prev Previous Post   Next Post Next
  #3   Spotlight this post!  
Unread 28-12-2004, 00:28
jude's Avatar
jude jude is offline
Registered User
#0116 (Epsilon Delta)
Team Role: Mentor
 
Join Date: Dec 2004
Rookie Year: 2004
Location: Herndon, Virginia
Posts: 3
jude is on a distinguished road
Send a message via AIM to jude
Re: boolean

You can get rid of the #defines by using an enum:
Code:
typedef enum {TRUE=1, FALSE=0} bool;
There's also a small practical benefit for this approach:

Some compilers will be able to do some extra type-checking against the enum values, and warn you if you accidentily try to do something like "bool b_Var = 5".


Quote:
Originally Posted by Joe Ross
There is no boolean variable type in C. Most people declare it as char (or unsigned char) and use the value 0 for false and 1 (or any value != 0) for true.

Through the use of #defines and typedefs, you can emulate it, though.

Code:
typedef unsigned char bool
#define TRUE 1
#define FALSE 0
Then just use the variable type bool and the values TRUE and FALSE.
 


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Boolean statement blindguyinanorg Programming 2 15-02-2004 07:31


All times are GMT -5. The time now is 02:53.

The Chief Delphi Forums are sponsored by Innovation First International, Inc.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi