vfprintf

Writes output to a stream under format control

Local Servers:blocking
Remote Servers:blocking
Classification:ANSI
Platform:NLM
Service:Stream I/O

Syntax

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

Parameters

fp
(IN) Points to the file.
format
(IN) Points to the format control string.
arg
(IN) Specifies a variable argument.

Return Values

The vfprintf function returns the number of characters written or a negative value if an output error occurred. If an error occurs, errno is set.

Remarks

The vfprintf function writes output to the file pointed to by fp under control of the argument format. The format string is described under the description for printf. The vfprintf function is equivalent to fprintf, with the variable argument list replaced with arg, which has been initialized by the va_start macro.

See Also

fprintf, printf, sprintf, va_arg, va_end, va_start (NDK: Program Management)

vfprintf Example

  #include <stdarg.h>  
  #include <stdio.h>  
   
  extern FILE *LogFile;  
   
  void errmsg          /* A GENERAL ERROR ROUTINE */  
  (char *format, ... )  
  {  
     va_list arglist;  
     va_start (arglist, format);  
     vfprintf (stderr, format, arglist);  
     va_end  (arglist );  
     if  (LogFile != NULL)  
     {  
        va_start (arglist, format);  
        vfprintf (LogFile, format, arglist);  
        va_end (arglist);  
     }  
  }