vfprintf функция

Forums:

#include stdarg.h>
#include stdio.h>
int vfprintf(FILE * restrict stream,  const char * restrict format, va_list arg);

Функция vfprintf() эквивалентна функции fprintf с дополнительным аргументом arg ,
который должен быть инициализирован с помощью макроса va_start
(и возможно - последующими вызовами va_arg )

Функция vfprintf()
не вызывает макрос va_end

Об упомянутых макросах читайте здесь

Функция возвращает число переданных(видимо - "переданных в файл") символом - или
отрицательное значение если произошла ошибка вывода или кодировки.

7.19.6.8 The vfprintf function
Synopsis
#include stdarg.h>
#include stdio.h>
int vfprintf(FILE * restrict stream,
const char * restrict format,
va_list arg);
Description
The vfprintf function is equivalent to fprintf, with the variable argument list
replaced by arg, which shall have been initialized by the va_start macro (and
possibly subsequent va_arg calls). The vfprintf function does not invoke the
va_end macro.
248)
Returns
The vfprintf function returns the number of characters transmitted, or a negative
value if an output or encoding error occurred.

EXAMPLE The following shows the use of the vfprintf function in a general error-reporting routine.

#include stdarg.h>
#include stdio.h>
void error(char *function_name, char *format, ...)
{
va_list args;
va_start(args, format);
// print out name of function causing error
fprintf(stderr, "ERROR in %s: ", function_name);
// print out remainder of message
vfprintf(stderr, format, args);
va_end(args);
}