swscanf


swscanf

Reads in formatted data from a wide-character string

 #include <wchar.h> int swscanf ( const wchar_t * restrict wcs ,              const wchar_t * restrict format , ... ); 

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 

See Also

wscanf( ), fwscanf( ); wcstod( ), wcstol( ), and wcstoul( ); scanf( ), fscanf( ); fwprintf( ), wprintf( ), vfwprintf( ), and vwprintf( ); the example at wcsspn( ) in this chapter.



C(c) In a Nutshell
C in a Nutshell (In a Nutshell (OReilly))
ISBN: 0596006977
EAN: 2147483647
Year: 2006
Pages: 473

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net