fseek/fgetc puzzle

Thorsten Glaser t.glaser at tarent.de
Tue Feb 21 10:10:41 AEDT 2023


On Mon, 20 Feb 2023, Mitchell Dorrell wrote:

>The link mentions "ISO Sec. 7.9.5.3" presumably refers to the ISO/IEC
>9899:1990 version of the C standard, which is the section, "The fopen

Still present in C99 and the mid-January C23 draft.
Nōn-OCR quote from the latter (§7.23.5.3(7) fopen):

| When a file is opened with update mode (’+’ as the second or third
| character in the above list of mode argument values), both input and
| output may be performed on the associated stream. However, output
| shall not be directly followed by input without an intervening call to
| the fflush function or to a file positioning function (fseek, fsetpos,
| or rewind), and input shall not be directly followed by output without
| an intervening call to a file positioning function, unless the input
| operation encounters end-of-file. Opening (or creating) a text file
| with update mode may instead open (or create) a binary stream in some
| implementations.

This sadly rules out fflush() for this case, even if it works here.

bye,
//mirabilos
-- 
Infrastrukturexperte • tarent solutions GmbH
Am Dickobskreuz 10, D-53121 Bonn • http://www.tarent.de/
Telephon +49 228 54881-393 • Fax: +49 228 54881-235
HRB AG Bonn 5168 • USt-ID (VAT): DE122264941
Geschäftsführer: Dr. Stefan Barth, Kai Ebenrett, Boris Esser, Alexander Steeg

                        ****************************************************
/⁀\ The UTF-8 Ribbon
╲ ╱ Campaign against      Mit dem tarent-Newsletter nichts mehr verpassen:
 ╳  HTML eMail! Also,     https://www.tarent.de/newsletter
╱ ╲ header encryption!
                        ****************************************************


More information about the openssh-unix-dev mailing list