User Tools

Site Tools


c:stdio.h:vprintf

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

c:stdio.h:vprintf [2024/02/16 01:05] (current)
Line 1: Line 1:
 +{{keywords>wiki library source code example reference}}
 +====== vprintf ======
 +
 +<code c>
 +    int vprintf(const char *format, va_list arg);
 +</code>
 +Equivalent to printf 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).\\
 +is used to generate a string from a format string and then print to standard output stdout.
 +**vprintf** can understood as a combination of [[c:stdio.h:puts|]] and [[c:stdio.h:vsprintf|]].
 +
 +===== C Sourcecode Example =====
 +<code c>
 +/* 
 + * vprintf example code
 + * http://code-reference.com/c/stdio.h/vprintf 
 + */
 +
 +#include <stdio.h> /* including standard library */
 +//#include <windows.h> /* uncomment this for Windows */
 +
 +#include <stdarg.h>  /* included for va_list */
 +
 +int myprintf( char const * format, ... )
 +{
 +  va_list args;
 +  int n;
 +
 +  printf("vprintf example :");
 +  va_start( args, format );
 +  n = vprintf( format, args );
 +  va_end( args );
 +
 +  return n;
 +}
 +
 +int main ( void )
 +{
 +  char string[] ="Hello";
 +
 +   myprintf( " %s World\n", string);
 +
 +   return 0;
 +}
 +
 +</code>
 +
 +==== output ====
 +
 +
 +    output:  ./vprintf 
 +    vprintf example : Hello World
  

on the occasion of the current invasion of Russia in Ukraine

Russian Stop this War
c/stdio.h/vprintf.txt · Last modified: 2024/02/16 01:05 (external edit)

Impressum Datenschutz