{{keywords>wiki library source code example reference}}
===== vsprintf =====
int vsprintf(char *str, const char *format, va_list arg);
generate a string from a format string.
For this purpose, the buffer that is passed as first argument, the format string is copied and replaces the substitution symbol with the given parameters.
===== C Sourcecode Example =====
/*
* vsprintf example code
* http://code-reference.com/c/stdio.h/vsprintf
*/
#include /* including standard library */
//#include /* uncomment this for Windows */
#include
int myprintf( char const * format, ... )
{
va_list args;
int n;
char buffer[200];
va_start( args, format );
vsprintf( buffer, format, args );
va_end( args );
return printf("vsprintf example : %s", buffer);
}
int main (void)
{
char string[] ="Hello";
myprintf( " %s World\n", string);
return 0;
}
==== output ====
output: ./vsprintf
vsprintf example : Hello World