FAT | RFS | XFS

vprintf()

PROTOTYPE

#include <stdio.h>

int vprintf(const char *format, va_list ap);

DESCRIPTION

vprintf() writes formatted text to the open regular file identified by stdout 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, vprintf() updates stdout’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 stdout is not the handle of a file open in write or append mode.
EFAULT format equals NULL.
ENOSPC The volume is full.

EXAMPLE

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

  va_start(ap, format);
  if ((r_value = vprintf(format, ap)) < 0)
    perror("vprintf() failed");
  va_end(ap);
}