How do we check if a pointer is NULL pointer?

前端 未结 8 2246
一向
一向 2020-12-01 11:56

I always think simply if(p != NULL){..} will do the job. But after reading this Stack Overflow question, it seems not.

So what\'s the canonical way to c

8条回答
  •  执念已碎
    2020-12-01 12:21

    Apparently the thread you refer is about C++.

    In C your snippet will always work. I like the simpler if (p) { /* ... */ }.

提交回复
热议问题