Deutsch English Français Italiano |
<voaovv$ocot$1@dont-email.me> View for Bookmarking (what is this?) Look up another Usenet article |
Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: Janis Papanagnou <janis_papanagnou+ng@hotmail.com> Newsgroups: comp.lang.c Subject: Re: Buffer contents well-defined after fgets() reaches EOF ? Date: Sun, 9 Feb 2025 18:34:55 +0100 Organization: A noiseless patient Spider Lines: 29 Message-ID: <voaovv$ocot$1@dont-email.me> References: <vo9g74$fu8u$1@dont-email.me> <vo9hlo$g0to$1@dont-email.me> <vo9ki6$gib5$1@dont-email.me> <voahgv$mdud$2@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Injection-Date: Sun, 09 Feb 2025 18:34:56 +0100 (CET) Injection-Info: dont-email.me; posting-host="2863fb45892f80e3bb8d5dd8ab68d22c"; logging-data="799517"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19BX04c5Yf//xuTJ3FDEeTF" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 Cancel-Lock: sha1:6ia4LX/mLAsgjVpGqRTOGiqLB74= In-Reply-To: <voahgv$mdud$2@dont-email.me> X-Enigmail-Draft-Status: N1110 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