vscanf - C stdio.h

C examples for stdio.h:vscanf

Type

function

From


<cstdio>
<stdio.h>

Description

Read formatted data into variable argument list

Prototype

int vscanf ( const char * format, va_list arg );

Parameters

ParameterDescription
format a format string
arg a variable arguments list initialized with va_start.

Return Value

On success, the function returns the number the argument filled.

Demo Code


#include <stdio.h>
#include <stdarg.h>

void GetMatches ( const char * format, ... )
{
  va_list args;/* www  .java  2  s . com*/
  va_start (args, format);
  vscanf (format, args);
  va_end (args);
}

int main ()
{
  int val;
  char str[100];

  printf ("Please enter a number and a word: ");

  fflush (stdout);

  GetMatches (" %d %99s ", &val, str);

  printf ("Number read: %d\nWord read: %s\n", val, str);

  return 0;
}

Related Tutorials