News for hackers. Stuff that matters.
Re:There are many ways to fail to read a file in a C program by anonymoushn on Monday August 15, 2022 @08:11AM (#32468653)
That is in fact what he does in the article!
Re:There are many ways to fail to read a file in a C program by phao on Monday August 15, 2022 @08:21AM (#32468739)
Right, but is he relying on the standard (the C language specification is an ISO standard, btw) behavior guaranteed by the language? Or is it talking about some implementation specific behavior that also happens to fall into the name of fopen, fread, etc?

For C programmers, talking about "standard" implies a quite particular meaning.

Re:There are many ways to fail to read a file in a C program by anonymoushn on Monday August 15, 2022 @08:38AM (#32468893)
I did not purchase a C standard from ISO, but a draft specifies that text streams and binary streams are both supported, and that text streams may perform all sorts of implementation-defined destruction on your data. Some small part of the article seems to be related to this.
Re:There are many ways to fail to read a file in a C program by phao on Monday August 15, 2022 @01:34PM (#32472701)
About drafts...

Iirc, the last draft before final publication is free and it's just as good.

As another user replied, there is more going on in the post than what is specified, guaranteed, etc, by the standard.

The practice of C programming in an actual system using non-standard things is important. Also, the C language does have its problems, even within the standard. However, pinning to C problems of a not-so-helpful implementation, library, system, etc, is unfair and unhelpful I believe.

Re:There are many ways to fail to read a file in a C program by bregma on Monday August 15, 2022 @01:20PM (#32472517)
The streams discussed in the article are neither text nor binary. They're record-oriented files, which are not supported by the C language standard. Operations on record-oriented files are a vendor extension that work however the vendor says they work.

On the other hand, record-oriented files work just peachy with ISO standard COBOL.