Liste des Groupes | Revenir à col misc |
Peter Flass <peter_flass@yahoo.com> wrote or quoted:The whole context of 'C' was that COMPETENT PROGRAMMERSThe Natural Philosopher <tnp@invalid.invalid> wrote:You could write a wrapper for printf, "myprintf",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.
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; }
Les messages affichés proviennent d'usenet.