Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What does (char *)0 mean in c?

Tags:

c

syntax

if ( fgets( line, sizeof(line), stdin ) == (char*) 0 )...

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

like image 770
compile-fan Avatar asked Dec 28 '22 20:12

compile-fan


1 Answers

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))
like image 190
David Heffernan Avatar answered Dec 30 '22 09:12

David Heffernan