Are boolean statements supported in C?
if not how would you work around this?
Are boolean statements supported in C?
if not how would you work around this?
>Are boolean statements supported in C?
Absolutely. What are you trying to do?
My best code is written with the delete key.
when I declare bool whatever = true; I get compiler error "bool undeclared identifier"
Are you using C99? If so, this should work just peachy:
But in the more likely case that you're using C89, you'll need to use an int.Code:#include <stdbool.h> int main ( void ) { bool whatever = true; }
My best code is written with the delete key.
Prelude once told me to use this as an alternative.
However, using an int is just as easy and just as useful.Code:typedef enum {true, false} bool;
Or a char . . .
TRUE and FALSE are fairly common macros.
It is too clear and so it is hard to see.
A dunce once searched for fire with a lighted lantern.
Had he known what fire was,
He could have cooked his rice much sooner.
Ok, I got it working. On my box, I had use TRUE && FALSE in caps with out declaring bool ,ie:
Thanks all !Code:int main ( void ) { whatever = TRUE; }
Our mistake, we assumed you meant a standard implementation...
Quzah.
Hope is the first step on the road to disappointment.
It might be a little more intuitive to switch the order of true and false in your enum..Originally Posted by sand_man
Code:typedef enum {FALSE, TRUE} boolean;
>Prelude once told me to use this as an alternative.
Actually, it was probably more like this due to the common use of true, false, and bool:
One thing I certainly like about C++ is the introduction of namespaces to help with naming collisions.Code:typedef enum { BFALSE, BTRUE } bool_t;
My best code is written with the delete key.