December 2005
Beginner to intermediate
618 pages
20h 19m
English
swscanf
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.
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
Read now
Unlock full access