What does (char *)0 mean in c?

前端 未结 6 2184
臣服心动
臣服心动 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:26

    That's a rather odd way of writing a test for the return of a null pointer which indicates an error in fgets().

    I'd write it like this:

    if (!fgets(line, sizeof(line), stdin))
    

提交回复
热议问题