Warning: main(/www/www/htdocs/style/globals.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/v/vfprintf.html on line 1
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/globals.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/v/vfprintf.html on line 1
Warning: main(/www/www/htdocs/style/header.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/v/vfprintf.html on line 8
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/header.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/v/vfprintf.html on line 8
Write formatted output to a file (varargs)
#include <stdio.h>
#include <stdarg.h>
int vfprintf( FILE* fp,
const char* format,
va_list arg );
- fp
- The stream to which you want to send the output.
- format
- A string that specifies the format of the output.
The formatting string determines what additional arguments you need to
provide.
For more information, see
printf().
- arg
- A variable-argument list of the additional arguments, which you
must have initialized with the
va_start()
macro.
libc
Use the -l c option to
qcc
to link against this library.
This library is usually included automatically.
The vfprintf() function writes output to the file pointed to by
fp, under control of the argument format.
The vfprintf() function is a “varargs” version of
fprintf().
The number of characters written,
or a negative value if an output error occurred
(errno
is set).
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
FILE *LogFile;
/* a general error routine */
void errmsg( const 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 );
}
}
int main( void )
{
LogFile = fopen( "error.log", "w" );
errmsg( "%s %d %s", "Failed", 100, "times" );
return EXIT_SUCCESS;
}
ANSI,
POSIX 1003.1
Safety: | |
Cancellation point |
No |
Interrupt handler |
No |
Signal handler |
No |
Thread |
Yes |
errno,
fprintf(),
fwprintf(),
printf(),
snprintf(),
sprintf(),
swprintf(),
va_start(),
vfwprintf(),
vprintf(),
vsnprintf(),
vsprintf(),
vswprintf(),
vwprintf(),
wprintf()
Warning: main(/www/www/htdocs/style/footer.php) [function.main]: failed to open stream: No such file or directory in /www/www/docs/6.4.1/neutrino/lib_ref/v/vfprintf.html on line 183
Warning: main() [function.include]: Failed opening '/www/www/htdocs/style/footer.php' for inclusion (include_path='.:/www/www/common:/www/www/php/lib/php') in /www/www/docs/6.4.1/neutrino/lib_ref/v/vfprintf.html on line 183