Boolalpha

Hello, can someone please explain how cout<<boolalpha works in terms of comparing whether a statement is true or false? Thanks.

It just formats a bool into a “true” or “false” string for outputting to std::cout.

int main()
{
    std::cout << true; //prints 1
    std::cout << std::boolalpha << true; //prints "true"
    return 0;
}

Thank you so much!! =)

Privacy & Terms