function
<cwchar>

vswscanf

int vswscanf (const wchar_t* ws, const wchar_t* format, va_list arg);
Read formatted data from wide string into variable argument list
Reads data from ws and stores them according to parameter format into the locations pointed by the elements in the variable argument list identified by arg.

Internally, the function retrieves arguments from the list identified by arg as if va_arg was used on it, and thus the state of arg is likely to be altered by the call.

In any case, arg should have been initialized by va_start at some point before the call, and it is expected to be released by va_end at some point after the call.

This is the wide character equivalent of vsscanf (<cstdio>).

Parameters

ws
C wide string that the function processes as its source to retrieve the data.
format
C wide string that contains a format string that follows the same specifications as format in scanf (see scanf for details).
Notice though, that all format specifiers have the same meaning as in scanf; therefore, %lc shall be used to read a wide character (and not %c), as well as %ls shall be used for wide strings (and not %s).
arg
A value identifying a variable arguments list initialized with va_start.
va_list is a special type defined in <cstdarg>.

Return Value

On success, the function returns the number of items in the argument list successfully filled. This count can match the expected number of items or be less -even zero- in the case of a matching failure.
In the case of an input failure before any data could be successfully interpreted, EOF is returned.

Example

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/* vswscanf example */
#include <stdarg.h>
#include <wchar.h>

void GetWideMatches ( const wchar_t * str, const wchar_t * format, ... )
{
  va_list args;
  va_start (args, format);
  vswscanf (str, format, args);
  va_end (args);
}

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

  GetWideMatches ( L"99 bottles of beer on the wall", L" %d %ls ", &val, buf);

  wprintf (L"Product: %ls\nQuantity: %d\n", buf, val);

  return 0;
}


Possible output:
Product: bottles
Quantity: 99

See also

vcscanf