On 26.07.2017 05:02, Walter Bright wrote:
On 7/25/2017 5:56 PM, Andrei Alexandrescu wrote:
I'd think that would be the case, but failed to find a fgetc
implementation that mentions it's undefined for a null FILE*. Is there
a link? Thx. -- Andrei
The documentation for DMC++ fgetc() is:
https://digitalmars.com/rtl/stdio.html#fgetc
and says:
"Returns the character just read on success, or EOF if end-of-file or
a read error is encountered."
The implementation checks for fp being NULL and returns EOF if it is.
The C mindset is that this check is a waste of precious processing
resources and morally wrong, as only a fool would pass NULL anyway, and
fools deserve to get UB.