Oppolzer - Informatik / Blog


Blog-Hauptseite      Neuester Artikel      Älterer Artikel      Neuerer Artikel      Älterer gleiche Kategorie      Neuerer gleiche Kategorie

Hercules - Ausgabe variabel langer Sätze mit C

Subject:

Re: [hercules-os380] Re: variable length record

From:

Bernd Oppolzer <bernd.oppolzer@T-ONLINE.DE>

Reply-To:

Date:

2013.07.30 20:03:00


Am 30.07.2013 19:46, schrieb K.V.:
> --- In hercules-os380@yahoogroups.com, Bernd Oppolzer <berndoppolzer@...> wrote:
>> This is a matter of how the ANSI C library functions are defined.
>>
>> No hercules or GCC topic, in fact. When I wrote some programs in C
>> for MVS mainframe, I suddenly discovered (some time ago) that the
>> fopen - fprintf - fclose calls all returned zero etc., although
>> the PDS to which I wrote was full. I had many B37 messages in
>> the JESMSGLG etc., but the
>> C runtime ignored the situation completely.
> I don't think the C library is allowed to do that.
> Also note that fopen returning 0 is a sign of failure.

sorry, returning zero is of course not correct.

fopen returns the file handle, fprintf (IIRC) the number of bytes written, and I
don't know what fclose returns at the moment ... but there were no ABENDs or
anything ... and I observed the same behaviour on Windows and OS/2, when the
disk partition was full - when I don't check using ferror, all seems well and
the written file is simply truncated ... there is no place on these platforms
where a message (like JESMSGLG) could appear.

My opinion is that the C runtime (ANSI library) has to record the file status
(has there been an error or not) in the FILE descriptor, to be able to answer to
the ferror call, but if the programmer decides not to ask for the error status,
it's his or her fault. That's how it is designed.

Kind regards

Bernd

Blog-Hauptseite      Neuester Artikel      Älterer Artikel      Neuerer Artikel      Älterer gleiche Kategorie      Neuerer gleiche Kategorie