Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C

false — Boolean false constant

In C23, false is a keyword representing a constant of type bool with value 0. It requires no <stdbool.h> header.

Version: C23; repository compiler flag, production runtime not attested

Syntax

false

In C23, false is a keyword representing a predefined constant of type bool with value 0. Its counterpart, true, has value 1. N3096 specifies these constants in section 6.4.4.5.

Use false to initialize or assign a Boolean state, for example bool ready = false;. In C23, neither bool nor false requires <stdbool.h>. false is a constant, not a variable, so you cannot assign a value to it.

In the example, ready initially represents false. The cast (int)ready allows %d to print 0, and the condition !ready causes not ready to be printed.

Examples

#include <stdio.h>

int main(void)
{
    bool ready = false;
    printf("%d\n", (int)ready);

    if (!ready) {
        puts("not ready");
    }

    return 0;
}

Result

0
not ready

The displayed code and declared result were verified in an isolated environment using the method recorded in the verification evidence for this exact version.

Sources