What does (char *)0 mean in c?

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

    The line checks if fgets return 0. The cast to char* is only to match the return type of fgets:

    char * fgets ( char * str, int num, FILE * stream );
    

    But 0 is implicit converted to char* if you remove it.

    If you need more information on fgets look here

提交回复
热议问题