Sujet : Re: Buffer contents well-defined after fgets() reaches EOF ?
De : janis_papanagnou+ng (at) *nospam* hotmail.com (Janis Papanagnou)
Groupes : comp.lang.cDate : 09. Feb 2025, 18:34:55
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <voaovv$ocot$1@dont-email.me>
References : 1 2 3 4
User-Agent : Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0
On 09.02.2025 16:27, Andrey Tarasevich wrote:
On Sat 2/8/2025 11:13 PM, Janis Papanagnou wrote:
But now I wanted to ignore all data that I got for fgets() != NULL
in the loop. And I hoped that *after* the loop the last read data is
still valid.
As Michael already noted it depends on what you consider as the last
piece of valid data in your file.
I have a strong opinion of a text file concerning line terminators;
I answered that in my reply Michael.
Say, what do you want to see as "the
last line" in a file that ends with
abracadabra\n<EOF here>
?
Is "abracadabra" the last line? Or is the last line supposed to be empty
in this case?
If "\n" is a string literal (2 characters, '\' and 'n') then it's an
incomplete line (as to my standards), if it's meant as a <LF> control
character then it's complete. (Similar with <CR> on old Apple/Macs and
<CR><LF> on DOS-alike systems.)
Janis