Thread: Program with boolean function

  1. #1
    Registered User
    Join Date
    Feb 2008
    Posts
    39

    Program with boolean function

    anyone teach me about boolean function in C program... give me any one example program

  2. #2
    Kernel hacker
    Join Date
    Jul 2007
    Location
    Farncombe, Surrey, England
    Posts
    15,677
    What do you want to understand?

    C doesn't have a "boolean type", so I presume you are referring to boolean operators, which would be the:
    && operator
    || operator
    and
    ! operator.

    Some or all of those are likely to appear in any application of some complexity, e.g. anything a bit more complex than "Hello World" [actually they are probably part of that too, as I expect printf() to use them - but you can't see that in usual builds].

    --
    Mats
    Compilers can produce warnings - make the compiler programmers happy: Use them!
    Please don't PM me for help - and no, I don't do help over instant messengers.

  3. #3
    Registered User
    Join Date
    Feb 2008
    Posts
    19
    maybe you mean the type "_Bool" and "bool"?

    _Bool can only have value 0 and 1. 0 = neg and 1 = positive.

    bool needs you include the <stdbool.h> and a variable of type bool can have the value "true" and "false".
    But just use _Bool and don't include anything.

    I have no idea if it's optional or is C standard. But that worked with all compilers I used. (all recent)

    Just checked the pdf linked in the pinned thread and apparently both _Bool and bool are C standard.
    Last edited by 2112; 02-18-2008 at 10:53 AM.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. dllimport function not allowed
    By steve1_rm in forum C++ Programming
    Replies: 5
    Last Post: 03-11-2008, 03:33 AM
  2. c++ linking problem for x11
    By kron in forum Linux Programming
    Replies: 1
    Last Post: 11-19-2004, 10:18 AM
  3. Replies: 2
    Last Post: 05-10-2002, 04:16 PM
  4. I need help with passing pointers in function calls
    By vien_mti in forum C Programming
    Replies: 3
    Last Post: 04-24-2002, 10:00 AM
  5. qt help
    By Unregistered in forum Linux Programming
    Replies: 1
    Last Post: 04-20-2002, 09:51 AM