🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: net.lang.c
Article #9228

Re: fgets() returns NULL at EOF??

#9228
From: karl
Date: Wed, 03 Sep 1986 17:32
20 lines
1302 bytes
sun!guy (Guy Harris) writes:
>Now, you can ask "why does 'fgets' return a value of type 'char *'?"  at
>this point.  It returns a pointer to the buffer that it just filled in;
>obviously *somebody* found this useful, although I don't find it so.

Me neither.  It sounds like a "why not?" situation.

>If "fgets" didn't return that pointer, it could have been defined as
>returning a value of type "int" instead, and that value would have been 0 on
>success and EOF on failure.

Better yet, return the number of characters read (so 0 on failure).

>It's too late to change it, though.

Not without changing the name again.  (That's how fgets() evolved from
gets(), though the latter still exists.)

Karl W. Z. Heuer (ima!haddock!karl; karl@haddock.isc.com), The Walking Lint
Technical Details
Message-ID: <86900031@haddock>
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!think!ima!haddock!karl
References: <6444@sun.uucp>

Show Full Headers
Complete Article Headers
Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP
Path: arc1-ca.pugleaf.net!utzoo!mnetor!seismo!think!ima!haddock!karl
From: karl@haddock
Newsgroups: net.lang.c
Subject: Re: fgets() returns NULL at EOF??
Message-ID: <86900031@haddock>
Date: Wed, 3-Sep-86 13:32:00 EDT
Article-I.D.: haddock.86900031
Posted: Wed Sep  3 13:32:00 1986
Date-Received: Wed, 3-Sep-86 21:51:14 EDT
References: <6444@sun.uucp>
Lines: 20
Nf-ID: #R:sun.uucp:6444:haddock:86900031:000:774
Nf-From: haddock!karl    Sep  3 13:32:00 1986