What does (char *)0 mean in c?

前端 未结 6 2161
臣服心动
臣服心动 2020-12-19 17:47
if ( fgets( line, sizeof(line), stdin ) == (char*) 0 )...

I don\'t understand what this line does,anyone knows?

6条回答
  •  借酒劲吻你
    2020-12-19 18:48

    It means a null pointer to char. It would be the same if you replace the (char*)0 with NULL. In this particular case it is checking if there is nothing more to read from the stdin. I think is just a way to be cryptic and showing some spectacular and beautiful features. If you replace it with a NULL you gain in readability without changing the semantic.

提交回复
热议问题