What is the return value of feof () in a closed file?

for a FILE * stream, if I read as much data as possible, feof (stream) returns me a nonzero value. Then, if I create a stream, it feof (stream) will continue to return me a non-zero value? IS GUARANTEED?

+3
source share
4 answers

Calling pheof () in a closed file is meaningless (actually worse than meaningless - it is undefined, so anything can happen).

From standard C:

The value of the pointer to a FILE object is undefined after the linked file is closed (including standard text streams).

and

fclose , , , . ; . , , disassociated , setbuf setvbuf ( , ).

+12

fclose() FILE, . , " undefined".

+3

. feof() . - undefined. , - , , EOF.

, undefined C ... - , - .

Usenet comp.lang.c , DeathStation 9000, undefined. , , undefined C: -)

+2

feof().

, f * fclose.

+1

Source: https://habr.com/ru/post/1698001/


All Articles