Help us and donate little Bitcoins to pay the server costs: 1AXLPuRUBYc1JczTW4XS65GL6oWjNP2Vt2

User Tools

Site Tools


Sidebar

Programming Reference/Librarys

Question & Answer







because of the inhumane working conditions at amazon in Germany, I will offer the Amazon app no more! (ARD Reportage)
c:stdio.h:vfprintf

vfprintf

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

Equivalent to fprintf with variable argument list replaced by arg, which must have been initialised by the va_start macro (and may have been used in calls to va_arg).

C Sourcecode Example

/* 
 * vfprintf example code
 * http://code-reference.com/c/stdio.h/vfprintf 
 */
 
#include <stdio.h> /* including standard library */
//#include <windows.h> /* uncomment this for Windows */
 
#include <stdarg.h>
 
int myfprintf( FILE *file, char const * format, ... )
{
  va_list args;
  int n;
 
  va_start( args, format );
  n=vfprintf( file, format, args );
  va_end( args );
  fputs("vfprintf test line\n", file);
 
  return n;
}
 
int main (void)
{
  char string[] ="Hello";
  FILE * stream = fopen("test.txt","w");
  if(stream == 0) {
   perror("file problem");
  }
 
   myfprintf( stream, " %s World\n", string);
 
   fclose(stream);
 
   return 0;
}

output

test.txt
Hello World
vfprintf test line
advertising
c/stdio.h/vfprintf.txt · Last modified: 2013/01/22 22:02 (external edit)

The new Question & Answer System is online and waiting for your Questions about Programming problems http://ask.code-reference.com Impressum