What does (char *)0 mean in c?

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

    (char*)0 creates the "null" pointer. So you are seeing if the value of fgets is null.

    The documentation for fgets states that it returns null when there is an error or you have reached end of file.

    The full statement appears to be checking if you are at the end of the file, and if so breaking out (though that's a guess).

提交回复
热议问题