In c, in bool, true == 1 and false == 0?

Just to clarify, I found a similar answer, but for C ++, I'm a bit new to coding, so I'm not sure if it applies to C as well

Thanks for the future help!

-1


source to share


2 answers


More precisely, everything that is not is 0

true.



So, 1

true, but it also 2

, 3

... etc.

+2


source


You were neglecting which version of C you are worried about. Let's assume this is one:

http://www.open-std.org/jtc1/sc22/wg14/www/docs/n1570.pdf



As you can see from reading the spec, the standard definitions of true

and false

are 1 and 0, yes.

If you have a question about a different version of C or non-standard definitions for true

and false

, ask a more specific question.

+2


source







All Articles