What is !0 in C?

后端 未结 5 1800
傲寒
傲寒 2020-12-06 09:59

I know that in C, for if statements and comparisons FALSE = 0 and anything else equals true.

Hence,

int j = 40
int k = !j

k == 0 // this is true
         


        
5条回答
  •  萌比男神i
    2020-12-06 10:24

    Generally, yes, it'll become 1. That said even if that is guaranteed behavior (which I'm not sure of) I'd consider code that relied on that to be pretty awful.

    You can assume that it's a true value. I wouldn't assume anything more.

提交回复
热议问题