vsscanf - C stdio.h

C examples for stdio.h:vsscanf

Type

function

From


<cstdio>
<stdio.h>

Description

Read formatted data from string into variable argument list

Prototype

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

Parameters

ParameterDescription
s source data.
format a format string.
arg a variable arguments list.

Return Value

On success, the function returns the number of items filled.

Demo Code


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

void GetMatches ( const char * str, const char * format, ... )
{
  va_list args;//w w w  . ja va  2  s. com
  va_start (args, format);
  vsscanf (str, format, args);
  va_end (args);
}

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

  GetMatches ( "99 this is a test", " %d %s ", &val, buf);

  printf ("%s\n %d\n", buf, val);

  return 0;
}

Related Tutorials