C vscanf, vfscanf, and vsscanf

Syntax

C vscanf, vfscanf, and vsscanf have the following syntax.

  • int vscanf(char * restrict format, va_list arg_ptr);
  • int vfscanf(FILE * restrict stream, const char * restrict format,va_list arg_ptr);
  • int vsscanf(char * restrict buf, const char * restrict format, va_list arg_ptr);

C vscanf, vfscanf, and vsscanf methods are from stdarg.h and stdio.h.

Description

The functions vscanf(), vfscanf(), and vsscanf() are functionally equivalent to scanf(), fscanf(), and sscanf(), respectively, except that the argument list has been replaced by a pointer to a list of arguments. This pointer must be of type va_list, which is defined in the header stdarg.h.

Example


#include <stdio.h>
#include <stdarg.h>
//from w w w  .  j  a  va2  s  . c  o m
void get_message(char *format, ...)
{
  va_list ptr;

  va_start(ptr, format);

  vscanf(format, ptr);

  va_end(ptr);
}

int main(void)
{

  int i;
  printf("integer:");
  get_message(" %d ", &i);

  printf("%d", i);

  return 0;
}




















Home »
  C Language »
    Function Reference »




assert.h
ctype.h
math.h
setjmp.h
signal.h
stdio.h
stdlib.h
string.h
time.h
wctype.h