Sujet : Re: The joy of FORTRAN
De : 186283 (at) *nospam* ud0s4.net (186282@ud0s4.net)
Groupes : alt.folklore.computers comp.os.linux.miscDate : 02. Oct 2024, 08:34:13
Autres entêtes
Organisation : wokiesux
Message-ID : <6tydnW_-XuPramH7nZ2dnZfqn_WdnZ2d@earthlink.com>
References : 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
User-Agent : Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0
On 10/1/24 6:24 AM, Stefan Ram wrote:
Peter Flass <peter_flass@yahoo.com> wrote or quoted:
The Natural Philosopher <tnp@invalid.invalid> wrote:
printf("hello world"); That's bug proof.
Wait, what? Where’s your error checking? What if your printf fails?
Actually that’s one of the things I like least about C. It leaves all error
checking up to the programmer instead of having even a minimal handler for
errors not otherwise caught.
You could write a wrapper for printf, "myprintf",
that will call printf and then do minimal error handling.
#include <stdio.h>
#include <stdarg.h>
int myprintf( char const * format, ... )
{ va_list args;
va_start( args, format );
int const result = vprintf( format, args );
va_end( args );
if( result < 0 )fprintf
( stderr, "Error: printf failed with return code %d\n", result );
return result; }
The whole context of 'C' was that COMPETENT PROGRAMMERS
existed and could/would assess error conditions as THEY
chose to do so.
No 'nanny' stuff. If you write stuff that will nuke
all memory then all memory, or worse, will be nuked.
More modern langs, you don't even get the options/ops
to handle a lot of this stuff intelligently.