User Tools

Site Tools


Sidebar

Programming Reference/Librarys

Question & Answer

Q&A is closed







c:stdio.h:vsprintf

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 <stdio.h> /* including standard library */
//#include <windows.h> /* uncomment this for Windows */
 
#include <stdarg.h>
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
  

on the occasion of the current invasion of Russia in Ukraine

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

Impressum Datenschutz