bool in c

This is a discussion on bool in c within the C Programming forums, part of the General Programming Boards category; how to use bool function 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,475
    bool is true false.

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

    Code:
    #define TRUE 1
    #define FALSE 0
    I'm just trying to be a better person - My Name Is Earl

  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, 07: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, 07:43 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21