Thread: bool in c

  1. #1
    Registered User
    Join Date
    May 2008
    Posts
    9

    bool in c

    how to use bool function in c???

  2. #2
    Woof, woof! zacs7's Avatar
    Join Date
    Mar 2007
    Location
    Australia
    Posts
    3,459
    There is no 'boolean' type in C89, at least not until C99 stdbool.h

    If you don't want to use stdbool.h you can define your own (convention has it, true = 1, false = 0).

  3. #3
    and the hat of sweating
    Join Date
    Aug 2007
    Location
    Toronto, ON
    Posts
    3,545
    What do you mean by bool "function"?

  4. #4
    Its hard... But im here swgh's Avatar
    Join Date
    Apr 2005
    Location
    England
    Posts
    1,688
    bool is true false.

    In C, you can just define it, as zacs7 suggested.

    Code:
    #define TRUE 1
    #define FALSE 0
    Double Helix STL

  5. #5
    * noops's Avatar
    Join Date
    Jun 2008
    Posts
    108
    I like:
    Code:
    typedef enum BOOL {
         FALSE,
         TRUE
    } BOOL;
    But I am still new to C. I think the advantage with this method is that it allows you to declare a variable like:

    BOOL done = FALSE;

    Instead of:

    int done = FALSE;

    Am I missing any other differences between #define and typedef for a bool type?

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. passing params between managed c++ and unmanaged c++
    By cechen in forum C++ Programming
    Replies: 11
    Last Post: 02-03-2009, 08:46 AM
  2. Smart pointer class
    By Elysia in forum C++ Programming
    Replies: 63
    Last Post: 11-03-2007, 07:05 AM
  3. DirectInput help
    By Muphin in forum Game Programming
    Replies: 2
    Last Post: 09-10-2005, 11:52 AM
  4. Headers that use each other
    By nickname_changed in forum C++ Programming
    Replies: 7
    Last Post: 10-03-2003, 04:25 AM
  5. Need Help With an RPG Style Game
    By JayDog in forum Game Programming
    Replies: 6
    Last Post: 03-30-2003, 08:43 PM