Thread: Boolean data type

  1. #1
    Registered User
    Join Date
    Jul 2005
    Posts
    56

    Boolean data type

    Does C have a data type for boolean so i can do a boolean functions? If so, what library is it in?

  2. #2
    Registered User
    Join Date
    Jun 2005
    Posts
    28
    Yes, as of C99, but it's not a library. Just include <stdbool.h>.

    Code:
    #include <stdio.h>
    #include <stdbool.h>
    
    int main(int argc, char * * argv) {
    bool b = getc(stdin) == 't' ? true : false;
    if(b) printf("True\n");
    else printf("False\n");
    }

  3. #3
    Registered User
    Join Date
    Jul 2005
    Location
    Transcarpathia
    Posts
    49
    use 'int' for boolean type.
    what kind of boolean functions are you talking about?

  4. #4
    Registered User
    Join Date
    Jul 2005
    Posts
    56
    I am using Visual C and i get an error when I #include <stdbool.h>!! I think i found it. It seems to work with BOOL but not with bool

  5. #5
    ATH0 quzah's Avatar
    Join Date
    Oct 2001
    Posts
    14,826
    The actual type is _Bool, but it's macroed to bool. Visual C++, I'm assuming version 6, since that's what most people that use it around here have, is old, and doesn't support C99 fully.


    Quzah.
    Hope is the first step on the road to disappointment.

  6. #6
    Registered User
    Join Date
    Sep 2004
    Posts
    44
    Neither does Visual C++ 2003, nor 2005. Microsoft just doesn't support C99. They are entirely focused on C++, and it seems, they could care less about C.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. how do you resolve this error?
    By -EquinoX- in forum C Programming
    Replies: 32
    Last Post: 11-05-2008, 04:35 PM
  2. Using VC Toolkit 2003
    By Noobwaker in forum Windows Programming
    Replies: 8
    Last Post: 03-13-2006, 07:33 AM
  3. return a random data type?
    By Niara in forum C++ Programming
    Replies: 3
    Last Post: 10-25-2005, 12:58 PM
  4. Learning OpenGL
    By HQSneaker in forum C++ Programming
    Replies: 7
    Last Post: 08-06-2004, 08:57 AM
  5. gcc problem
    By bjdea1 in forum Linux Programming
    Replies: 13
    Last Post: 04-29-2002, 06:51 PM