FAT | RFS | XFS

vfprintf()

PROTOTYPE

#include <stdio.h>

int vfprintf(FILE *file, const char *format, va_list ap);

DESCRIPTION

vfprintf() writes formatted text to the open regular file identified by file at its current position, or end if open in append mode. format and the argument list provided by ap are interpreted according to Standard C’s output format string conventions.

If successful, vfprintf() updates the file’s status change and data modification timestamps, marks its metadata as dirty, advances its current position, and returns the number of characters written. Otherwise, it sets errno and returns a negative value.

ERROR CODES

EBADF file is not the handle of a file open in write or append mode.
EFAULT format equals NULL.
ENOSPC The volume is full.
ENXIO The volume has been removed.
EROFS The volume is read-only.

EXAMPLE

/*--------------------------------------------------------------------*/
/* print: equivalent of printf with message if error                  */
/*--------------------------------------------------------------------*/
int print(const char *format, ...)
{
  va_list ap;
  int result;

  va_start(ap, format);
  if ((result = vfprintf(stdout, format, ap)) < 0)
    perror("vfprintf() failed");
  va_end(ap);
}