Is NULL always false?

前端 未结 13 1641
孤城傲影
孤城傲影 2020-11-27 04:44

Is it safe to assume that NULL always translates to false in C?

void *somePtr = NULL;

if (!somePtr) {
  /* This will always be executed? */
}
<         


        
13条回答
  •  悲&欢浪女
    2020-11-27 05:31

    *NULL always targets to 0x00L. You can consider that false, but to be sure always do an explicit check.

提交回复
热议问题