User Tools

Site Tools


Sidebar

Programming Reference/Librarys

Question & Answer

Q&A is closed







c:stdio.h:vsscanf

vsscanf

int vsscanf(const char *restrict s, const char *restrict format, va_list arg);

description of vsscanf

The vscanf(), vfscanf(), and vsscanf() functions shall be equivalent to the scanf(), fscanf(), and sscanf() functions, respectively, except that instead of being called with a variable number of arguments, they are called with an argument list as defined in the <stdarg.h> header. These functions shall not invoke the va_end macro. As these functions invoke the va_arg macro, the value of ap after the return is unspecified.

#include <stdio.h>
#include <stdarg.h>
 
char buffer[80] = "6 7.0 hoopy";
 
int my_vfscanf(char *fmt, ...)
{
   va_list  argptr;
   int cnt;
 
   fflush(stdin);
 
   va_start(argptr, fmt);
   cnt = vsscanf(buffer, fmt, argptr);
   va_end(argptr);
 
   return(cnt);
}
 
 
int main(void)
{
   int inumber;
   float fnumber;
   char string[80];
 
   my_vfscanf("%d %f %s", &inumber, &fnumber, string);
   printf("%d * %f = %s\n", inumber, fnumber, string);
   return 0;
}

output of vsscanf c example

  6 * 7.000000 = hoopy

on the occasion of the current invasion of Russia in Ukraine

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

Impressum Datenschutz