Name
swscanf
Synopsis
Reads in formatted data from a wide-character string
#include <wchar.h> intswscanf
( const wchar_t * restrictwcs
, const wchar_t * restrictformat
, ... );
The swscanf()
function is
similar to wscanf()
, except that
it reads its input from the wide-character string addressed by the
first argument, wcs
, rather than from
stdin
. If swscanf()
reads to the end of the string,
it returns the value EOF
.
Example
double price = 0.0;
wchar_t wstr[ ] = L"Current price: $199.90";swscanf
( wstr, L"%*[^$]$%lf", &price); // Read price from string.
price *= 0.8; // Apply 20% discount.
printf( "New price: $%.2lf\n", price);
This code produces the following output:
New price: $159.92
Get C in a Nutshell now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.