Chapter Contents

Previous

Next
vfprintf

vfprintf



Write Formatted Output to a File

Portability: ISO/ANSI C conforming


SYNOPSIS
DESCRIPTION
RETURN VALUE
EXAMPLE
RELATED FUNCTIONS
SEE ALSO


SYNOPSIS

#include <stdarg.h>
#include <stdio.h>

int vfprintf(FILE *f, const char *format, va_list arg);


DESCRIPTION

vfprintf is equivalent to fprintf with arg replacing the variable-argument list. arg has been initialized by the va_start macro and possibly va_arg calls. vfprintf does not invoke the va_end macro. See va_arg, va_end, and va_start for details on varying-length argument-list functions.


RETURN VALUE

vfprintf returns the number of characters transmitted to the output stream or a negative value if an output error occurs.


EXAMPLE

This example sends an error message prefix with fprintf and sends the remaining text with vfprintf :

#include <stdarg.h>
#include <stdio.h>

void error(char *fname, char *format, ...)
{
   va_list args;
   va_start(args, format);
   fprintf(stderr, "ERROR in %s: ", fname);
   vfprintf(stderr, format, args);
   va_end(args);
}


RELATED FUNCTIONS

fprintf , va_start , vprintf


SEE ALSO


Chapter Contents

Previous

Next

Top of Page

Copyright © 2001 by SAS Institute Inc., Cary, NC, USA. All rights reserved.