Namespaces
Variants
Views
Actions

_Bool

From cppreference.com
< c‎ | keyword
Revision as of 10:04, 12 May 2014 by Newatthis (Talk | contribs)

Implements a Boolean type.

Keywords

_Bool

Example

#include <stdio.h>
 
int main(void)
{
    printf("sizeof(_Bool) = %zu\n", sizeof(_Bool));
 
    _Bool b;
    b = 2;
    printf("b  = %d\n", b);    // 2 or 1?
    printf("!b = %d\n", !b);   // 0
 
    b = 0;
    printf("!b = %d\n", !b);   // 1
 
    if (b) printf("true\n");   // false
    else   printf("false\n");
 
    return 0;
}

Possible output:

sizeof(_Bool) = 1
b  = 1
!b = 0
!b = 1
false