This repository has been archived on 2024-12-16. You can view files and clone it, but cannot push or open issues or pull requests.
CodeBlocksPortable/WATCOM/samples/clibexam/vfprintf.c

29 lines
568 B
C
Raw Normal View History

#include <stdio.h>
#include <stdarg.h>
FILE *LogFile;
/* a general error routine */
void errmsg( char *format, ... )
{
va_list arglist;
fprintf( stderr, "Error: " );
va_start( arglist, format );
vfprintf( stderr, format, arglist );
va_end( arglist );
if( LogFile != NULL ) {
fprintf( LogFile, "Error: " );
va_start( arglist, format );
vfprintf( LogFile, format, arglist );
va_end( arglist );
}
}
void main()
{
LogFile = fopen( "error.log", "w" );
errmsg( "%s %d %s", "Failed", 100, "times" );
}