What does (char *)0 mean in c?

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

    It is simply checking the results of fgets for null character pointer.

    According to cplusplus.com

    Return Value

    On success, the function returns the same str parameter. If the End-of-File is encountered and no characters have been read, the contents of str remain unchanged and a null pointer is returned.

    If an error occurs, a null pointer is returned.

    Use either ferror or feof to check whether an error happened or the End-of-File was reached.

提交回复
热议问题